# TCID-13132 supplied SQL context delivery

<!-- auto-oncall-optimization-record
{
  "schemaVersion": "auto-oncall-optimization-record-v1",
  "optimizationId": "tcid13132-supplied-sql-context-2026-09-08",
  "problems": [{
    "problemId": "supplied-sql-missing-from-evidence-prompt",
    "summary": "Frozen customer SQL exists in the scenario context file but is missing from the Evidence Agent prompt.",
    "status": "optimized_unverified",
    "applicability": "Runner-owned Evidence prompts for Provider-backed SQL target matching.",
    "issueKeys": ["TCID-13132"],
    "sourceRefs": ["https://tidb.atlassian.net/browse/TCID-13132#problem:supplied-sql-missing-from-evidence-prompt"],
    "signalTextIncludesAny": ["target SQL"],
    "observedThrough": "2026-09-08",
    "effectiveAt": "2026-09-07T18:23:02.336Z",
    "verifiedAt": null,
    "attemptedAction": "Deployed 363d4d0b; isolated read replay proves complete SQL reached Evidence and the exact target Digest was found. Deeper execution comparison and Jira refresh remain unverified.",
    "evidenceUrl": "https://tidb.atlassian.net/browse/TCID-13132"
  }]
}
-->

Owner: AOS runner to Evidence Agent input.
Base: `69d4ce5a1cb8fce754dca8542a9c00f7394bbe88`.
Historical replay: `40c29173-b31d-4d5e-b977-d91e11015426`.
The frozen context contains the customer SQL, but the first acquisition prompt
omits it and the historical Evidence Agent reads only its two Skills.
The correction reuses the existing bounded frozen extraction; it does not
consult later human comments, invent a Digest, change Provider execution, or
teach Final Response to repair upstream evidence.

Validation criterion: the deployed isolated TCID-13132 replay must show the
customer SQL in Evidence input and its use in target-specific acquisition.
Inspect exact returned SQL/Digest/plan and execution timing/row evidence
separately; successful input delivery alone is not a complete case diagnosis.
TiFlash metric scope and deeper incident causality remain independent gaps.

Validation: TypeScript build, focused diagnostic/runner tests, the complete
compiled test suite and all six isolated-runner tests pass locally. The tests
cover all three Providers in both execution modes, initial/refinement input,
frozen-comment propagation, exclusion of future Support SQL, and the Final
Response non-owner boundary. These tests do not invoke a model or Provider.

## Deployment and isolated replay

PR #1403 merged as `363d4d0b169ee64947f65fba23974f3036ab48d6`.
Release workflow: https://github.com/tidbcloud/aisupport/actions/runs/34150721125.
app-delivery PR #79464 merged the same image. Live root reported the exact SHA;
health/readiness returned HTTP 200. Clinic 31, Manus 7 and Wetech 63 were
installed with bundle
`3c9cd1c3d786bd339655304c55a2d95c472dbc4391dcbcad57995babeed339bd`.

Isolated Job `aos-replay-tcid-13132-0aca9ed0` ran once, in read mode:

- Run: `5f9cb4a4-ec38-45be-87a0-218614c36001`.
- Fingerprint: `8fdc25ce7873ae70793eb09f73e87988fdb910ee357b079c59c0f175ffc23b2d`.
- Started/finished: 2026-09-07 18:23:02.336–18:41:43.420 UTC; 1,121,084 ms.
- Response and Clinic acquisition complete; final failure codes empty.
  All three scenario executions, Router and Final Response succeeded.
- Judge: `different_but_valid`; final decision `human_required`.
- One local Kubernetes EOF interrupted collection only. The original Pod stayed
  Running with zero restarts; `--collect` exported that same run. No second
  analysis was submitted. Full archive, summary, logs and frozen publication
  were exported before the Job was deleted.

Live Evidence session `sess_349a7f6912a14e8dab9dcd04b6f8485c` contains the complete
frozen customer SQL. Round 2 discovered the same exact target Digest as the
human investigation and one 14.238937071-second EXPLAIN ANALYZE execution.
Two adjacent-window occurrences of that record are one execution, not a
latency-variance sample. A separate 12.833-second same-shape statement does not
expose its selected engine and must not be treated as an exact same-Digest or
controlled engine comparison.

The bounded input/acquisition criterion is reproduced successfully. The broader
same-Digest/equal-actual-rows/4.5–20.8-second comparison is not: no Digest-selected
plan query ran. Scenario Diagnostic requested phase/plan refinement after round
2, but only about 75 seconds remained, below the 120-second acquisition reserve.
The runner returned the valid existing packet rather than starting round 3;
this is budget-limited further acquisition, not the original finalization
timeout. The current Managed Clinic Slow Query operation has no SQL-text filter;
twelve narrowed discovery windows found the target but consumed time/context.
Future work should reduce that discovery cost before another budget increase.

TiFlash metrics remain unclassified empty, not healthy-state proof. SQL
deduplication worked, but cumulative query-latency handoff pressure still kept
9/15 observations. Judge also flagged the final answer's inconsistent evidence
strength for the proposed faster TiKV route; no new downstream patch was made.

Artifacts are in the private local replay directory
`~/.cache/auto-oncall-services/replays/tcid-13132-main-363d4d0b-20260908-collected/`.
No Jira/DB/Base publication was requested or performed. Keep the problem
`optimized_unverified` until the applicable reviewed-result refresh is complete;
do not clear the ticket's other gaps from this input repair.
