# Agent9 E2B Transient Retry

<!-- auto-oncall-optimization-record
{
  "schemaVersion": "auto-oncall-optimization-record-v1",
  "optimizationId": "agent9-e2b-transient-retry-2026-08-25",
  "problems": [
    {
      "problemId": "agent9-e2b-transient-fetch-failure-degrades-evidence",
      "summary": "A transient Agent9-to-E2B fetch failure terminated an otherwise read-only Managed Clinic call and left the Evidence Agent with partial evidence.",
      "status": "optimized_verified",
      "applicability": "Agent9-backed Auto-oncall Turns using E2B Runtime, Session Drive, or a read-only Managed Tool.",
      "issueKeys": ["TCID-13070"],
      "sourceRefs": ["https://tidb.atlassian.net/browse/TCID-13070#problem:agent9-e2b-transient-fetch-failure"],
      "signalTextIncludesAny": [
        "runtime_error: fetch failed",
        "e2b_request_retry",
        "TCID-13070"
      ],
      "observedThrough": "2026-08-25",
      "effectiveAt": "2026-08-25T08:25:58Z",
      "verifiedAt": "2026-08-25T09:01:03Z",
      "attemptedAction": "Retry one transient E2B request only at caller-declared idempotent boundaries, recover ambiguously accepted Sandbox creates by exact metadata, keep active Session Drive Sandboxes alive, and declare Managed Clinic v14 effect=read so its command dispatch may be retried without a Tool-name whitelist or Agent guess.",
      "evidenceUrl": "https://internal.us-west-2.agent.mem9.ai/api/sessions/sess_e81360e8f97d484e91fdedf9c5bd65ac"
    }
  ]
}
-->

- Owner: Agent9 E2B runtime boundary and Managed Clinic package manifest
- Source: TCID-13070 replay `ef8432e2-922d-415c-8439-f0b7612befe0` and
  post-change replay `f2fc8501-bf47-42cd-9074-3d3653551718`
- Implementation status: Agent9 PR #863 and Managed Clinic v14 are deployed to
  Agent9 internal production; the Auto Oncall Evidence Agent is migrated to the
  v14 package digest
- Effective status: `optimized_verified`

## Bounded problem

The replay completed after a different query succeeded, but one real Managed
Tool Sandbox request failed with `runtime_error: fetch failed`. The failed
read-only call was not retried and the Evidence Agent continued with partial
evidence. A separate long Agent9 Turn also proved that the five-minute E2B
Session Drive lease could expire while the Turn was still active.

## Intended change

Agent9 retries one transient E2B control-plane request at idempotent file,
lifecycle, and bootstrap boundaries. An ambiguously accepted Sandbox create is
first discovered by exact run metadata before one replacement create is
allowed. Managed Tool command dispatch is retried only when the immutable Tool
manifest declares `effect: read`; write, mixed, and undeclared effects retain
an unknown outcome after dispatch. Managed Clinic v14 supplies that read-only
contract, and the package builder includes it in the immutable package digest.

The E2B Session Drive provider also refreshes the Sandbox lease while a Turn
holds the session. Retry logs retain the exact stage and sanitized error
name/code without request options or credentials.

## Verification

Agent9 internal production ran API image `main-4be441bf9e53`. Managed Clinic v14
was loaded with package digest
`7ae11a3f90154c9f581f1290a0f7e883f7f57e18c8536f30a41b439f926346ea`,
and the Auto Oncall Evidence Agent installation and config both read back that
exact reference.

The deployed `mode=read` replay of TCID-13070 completed as run
`f2fc8501-bf47-42cd-9074-3d3653551718`. Its Agent9 trace exercised v14 across
multiple Provider rounds. The capacity Evidence Session remained alive for a
7-minute-14-second first Turn and a later round, beyond the former five-minute
lease risk, without an expired Session Drive Sandbox. Neither the run workspace
nor Agent9 logs contained `fetch failed`, `e2b_request_retry`, `runtime_error`,
or a Sandbox-expiry signal. No natural transient request occurred, so the
automatic retry branch was not triggered in this replay; Agent9's focused tests
cover that branch and the read-versus-write dispatch boundary.

Response generation completed and the independent Judge returned `ai_better`
with no AI gaps. Evidence status was separately degraded by
`sql_observability_source_required`; that was a bounded business-plan rejection,
not an E2B transport failure, and does not change this optimization's result.

## Next validation action

Monitor later Agent9-backed runs for a naturally occurring transient request.
When one occurs, verify `e2b_request_retry` records the sanitized real stage and
that the read-only Provider result remains complete. Track the separate
`sql_observability_source_required` planning gap independently.
