# Agent9 Clinic Batch Execution

<!-- auto-oncall-optimization-record
{
  "schemaVersion": "auto-oncall-optimization-record-v1",
  "optimizationId": "agent9-clinic-batch-execution-2026-08-25",
  "problems": [
    {
      "problemId": "agent9-clinic-per-query-sandbox-overhead",
      "summary": "Agent9 created one isolated Managed Tool Sandbox for every Clinic query, so a 77-query replay spent most of its wall time repeatedly provisioning Provider Executor sandboxes.",
      "status": "optimized_verified",
      "applicability": "Agent9-backed Auto-oncall evidence rounds using the Managed Clinic Tool.",
      "issueKeys": ["TCID-13070"],
      "sourceRefs": ["https://tidb.atlassian.net/browse/TCID-13070#problem:agent9-clinic-per-query-sandbox-overhead"],
      "signalTextIncludesAny": [
        "managed_auto_oncall_clinic",
        "Provider Executor",
        "TCID-13070"
      ],
      "observedThrough": "2026-08-25",
      "effectiveAt": "2026-08-25T10:27:18Z",
      "verifiedAt": "2026-08-25T10:46:18Z",
      "attemptedAction": "Execute up to twelve independent Clinic query entries with bounded concurrency inside one Managed Tool Sandbox per Evidence round while preserving per-query result, error, correction, coverage, and artifact semantics.",
      "evidenceUrl": "https://tidb.atlassian.net/browse/TCID-13070"
    }
  ]
}
-->

- Owner: Managed Clinic Provider Executor package and Agent9-backed Evidence
  materialization
- Source: TCID-13070 Agent9 replay `f2fc8501-bf47-42cd-9074-3d3653551718`
- Implementation status: deployed to Agent9 internal production and the
  Agent9-backed Auto Oncall branch runtime
- Effective status: `optimized_verified`

## Bounded problem

The prior replay completed in about 19 minutes 30 seconds and made 77 Managed
Clinic calls. Each call created a separate Tool Sandbox even though queries in
one Evidence round were independent and the Clinic contract already authorized
concurrent execution inside one deterministic batch.

## Intended change

One Evidence round sends at most twelve query entries in one Managed Clinic
call. The Tool executes at most six entries concurrently and preserves one
`provider-result-v1` success or safe error per stable `queryId`. Corrections are
separate same-Turn batches containing only changed failed entries. The runner
retains final-outcome materialization, bounded attempt metadata, query coverage,
canonical evidence references, the four-correction ceiling, and Scenario
refinement semantics.

## Verification

Managed Clinic v16 package digest
`16e0dc05209751a82a7a17e89d68f2a2ae1707f6212dff2528a33e993f0d8df6`
was loaded by Agent9 internal production and installed on the Auto Oncall
Evidence Agent at installation revision 7. The branch runtime image
`448187b4d60b0d612b8a09871ac716c5a3dcb1c0` was read back Ready with zero
restarts before the read-only replay.

TCID-13070 replay `fd3b2042-506f-4da8-9a60-e0b0bd293bf3` completed with HTTP
200 in 810 seconds and Judge verdict `ai_better`. Three initial Evidence rounds
and two authorized refinement rounds executed as five Managed Clinic calls
containing 56 independent query entries. All 56 entries materialized a bounded
result, no correction batch was needed, and final
`execution.evidenceAcquisition` was `complete` with no failure codes.

The prior baseline replay `f2fc8501-bf47-42cd-9074-3d3653551718` took about
1,170 seconds and created 77 Managed Tool calls. Scenario selection is
stochastic, so the 31% total-wall reduction is supporting evidence rather than
an isolated batch benchmark. The direct transport criterion is the reduction
from one Sandbox per query to one Sandbox per Evidence round while preserving
all per-query coverage and errors.

## Next validation action

Monitor later Agent9-backed Clinic replays for batch-level transport failures or
query starvation. Treat a query-specific Provider rejection independently; it
must not discard successful peers from the same batch.
