# Purpose-driven Slow Query evidence handoff

<!-- auto-oncall-optimization-record
{
  "schemaVersion": "auto-oncall-optimization-record-v1",
  "optimizationId": "purpose-driven-slow-query-handoff-2026-09-08",
  "problems": [
    {
      "problemId": "slow-query-purpose-summary-not-consumed",
      "summary": "Managed Slow Query evidence was copied into the diagnostic handoff without consuming Evidence Agent purpose-specific selection or synthesis.",
      "status": "candidate",
      "applicability": "Agent9 diagnostic rounds containing successful nonempty Slow Query results and an Evidence Agent summary referencing those same-round queries.",
      "issueKeys": ["TCID-13139"],
      "sourceRefs": ["https://tidb.atlassian.net/browse/TCID-13139#problem:slow-query-purpose-summary-not-consumed"],
      "signalTextIncludesAny": ["slow-query-purpose-summary-not-consumed"],
      "observedThrough": "2026-09-08",
      "effectiveAt": null,
      "verifiedAt": null,
      "attemptedAction": "Implement purpose-specific Slow Query summary projection while retaining runner-owned acquisition state and raw artifacts. Local materializer and Skill-release fixture tests passed. Frozen-source mechanical validation with an explicitly human-authored illustrative summary reduced the round handoff from 129169 to 22558 UTF-8 JSON bytes without changing raw artifact hashes or coverage. PR #1416 was deployed as 02bdc964; the 2026-09-09 read-only replay report records actual Agent summary use and remaining diagnostic limits without promoting optimization status.",
      "evidenceUrl": "https://tidb.atlassian.net/browse/TCID-13139"
    }
  ]
}
-->

Owner: Evidence Agent chooses relevant Slow Query facts; the runner materializes
their exact current-round references and owns acquisition state. Source: the
operator's request to give Evidence the overall problem summary and this
round's question, then select useful facts instead of forwarding every row.
Implementation status: PR #1416 deployed as `02bdc964` on 2026-09-09 (+08).
The mechanical result below remains distinct from actual Agent behavior.

The Scenario Diagnostic Agent supplies `problemSummary`; its existing
`question` supplies the current acquisition purpose. Managed Evidence may
return `slowQuerySummaries` with a statement and exact query IDs. A valid entry
replaces only the referenced successful nonempty Slow Query observations.
Unselected observations, query coverage, errors, gaps, and raw compact reports
remain runner-owned and unchanged. Invalid references discard only that summary
entry and preserve original facts. No semantic-equality gate is introduced.

The shared query-planning Skill calls for relevant execution groups and
discriminating contrasts, with explicit sample coverage and missing-field
limitations. It does not require all five rankings, pretend different server
top-N queries cover one complete population, or let Evidence decide causes,
diagnostic status, mitigation, or human ownership. Generic metric/log projection,
Provider limits, and single-fact/cumulative budgets are unchanged by this
optimization.

## Mechanical verification and remaining gap

- Materializer and immutable Skill-release fixture tests: 19 passed, 0 failed.
  Clinic and Wetech fixtures cover five-source summaries, untouched detail and
  metric observations, failed/empty queries, absent summaries, and invalid refs.
- Frozen source: TCID-13139 run `e4322416-536b-44ea-ba46-f7e9870b89e8`,
  workload-hotspot round 2. The unchanged Tool trace was passed to the production
  materializer twice, with and without an explicitly human-authored illustrative
  summary. No model, Provider, or full replay was run; frozen files were not
  changed.
- Compact serialized handoff: 129,169 to 22,558 UTF-8 bytes, 8 to 4 observations.
  All 12 raw compact-report hashes, 12 query-coverage entries, errors, gaps,
  acquisition completion, and the 3 nonselected observations were unchanged.
  Temporary outputs: `/tmp/aos-slow-summary-wiring-byMZwU`.

This verifies wiring and provenance, not that an Agent will choose a sufficient
summary or produce a better diagnosis. Actual post-deployment observations are
kept in the [three-case read-only verification report](../replay-verification/2026-09-09-diagnostic-context-efficiency.md).
Retain separate checks for summary selection, task/field coverage, causal
strength, and downstream completion. The operator has not authorized an
optimization-status promotion or case publication; this document does not mark
the ticket optimized from local size reduction, deployment, or a completed run.
