# Agent9 Clinic batch attempt materialization

<!-- auto-oncall-optimization-record
{
  "schemaVersion": "auto-oncall-optimization-record-v1",
  "optimizationId": "agent9-clinic-batch-attempt-materialization-2026-09-04",
  "problems": [
    {
      "problemId": "agent9-clinic-batch-failure-missing-from-attempts",
      "summary": "A query-less Agent9 Clinic batch runtime failure degraded final acquisition while being absent from the ordered Provider attempt history, and a later fully successful repair batch could not clear that recovered failure.",
      "status": "candidate",
      "applicability": "Agent9-backed Clinic evidence acquisition where a batch-level primary call fails before returning per-query results and a later repair call returns a complete primary batch in the same scenario.",
      "issueKeys": ["ST-2933"],
      "sourceRefs": ["https://tidb.atlassian.net/browse/ST-2933#problem:agent9-clinic-batch-failure-missing-from-attempts"],
      "signalTextIncludesAny": ["runtime_error", "providerQueryAttempts", "evidence_acquisition_degraded"],
      "observedThrough": "2026-09-04",
      "effectiveAt": null,
      "verifiedAt": null,
      "attemptedAction": "Materialize a bounded provider-batch attempt for query-less Clinic failures, retain its order, and exclude the failure from final acquisition only after a later batch completes every primary result.",
      "evidenceUrl": "https://tidb.atlassian.net/browse/ST-2933"
    }
  ]
}
-->

- Owner: auto-oncall-services runner materialization
- Source reference: ST-2933
- Implementation status: candidate
- Effective status: candidate

## Bounded problem

Agent9 can fail a Clinic batch before it returns per-query results. The runtime
summary retained that failure, but the ordered attempt projection required a
`queryId` and silently omitted it. If a later correction returned a fully
successful primary batch, the anonymous earlier call also remained an effective
failure, leaving acquisition degraded even though all visible queries completed.

## Change

The runner records a query-less failed Clinic call as the stable bounded
`provider-batch` attempt. A later successful Clinic batch clears earlier
anonymous batch failures from final status only when every primary result in
that batch succeeds. The attempt history remains ordered and auditable, and a
batch failure without such a recovery continues to degrade acquisition.

## Verification

A deterministic runner regression covers a batch-level `runtime_error` followed
by a two-query successful repair batch. It requires complete acquisition, empty
final failure codes, and an ordered attempt history containing the batch failure
before both successful queries. The existing unrecovered runtime-error test
continues to require the failure code.

## Unresolved gaps

The underlying Tool or network cause of ST-2933's runtime error is not present
in the frozen context and is outside this materialization repair.

## Next validation action

After deployment, replay ST-2933 in read mode and confirm the runtime failure is
auditable while a fully successful repair batch yields complete acquisition.
