# Agent9 Scenario Context Projection

<!-- auto-oncall-optimization-record
{
  "schemaVersion": "auto-oncall-optimization-record-v1",
  "optimizationId": "agent9-scenario-context-projection-2026-08-21",
  "problems": [
    {
      "problemId": "agent9-evidence-agent-scenario-context-unavailable",
      "summary": "The Agent9 adapter projected only generic workspace directories, so runner-owned files inside an Evidence Agent's current scenario workspace were absent from its Session Drive.",
      "status": "optimized_unverified",
      "applicability": "Agent9-backed Evidence Agent turns that need runner-owned immutable files from their exact current scenario workspace.",
      "issueKeys": ["ST-2865"],
      "sourceRefs": ["https://tidb.atlassian.net/browse/ST-2865#problem:agent9-evidence-agent-scenario-context-unavailable"],
      "signalTextIncludesAny": [
        "agent9 evidence agent read_file failed",
        "current scenario context absent from session drive",
        "clinic-metrics-context.json not found"
      ],
      "observedThrough": "2026-08-21",
      "effectiveAt": "2026-08-21T03:38:18Z",
      "verifiedAt": null,
      "attemptedAction": "Project the exact scenario context directory through the existing Agent9 Session Drive adapter and make the common provider Skill read the runner-owned context path instead of the inaccessible parent ticket input path.",
      "evidenceUrl": "https://github.com/tidbcloud/aisupport/pull/1052"
    }
  ]
}
-->

- Owner: Agent9 workspace adapter and runner-owned scenario context
- Source: ST-2865 Agent9 replay
- Implementation status: deployed from `aa103408970e9492873dd53621ab14bb2788ddd3`
- Effective status: `optimized_unverified`

## Bounded problem

The Evidence Agent thread uses one scenario directory as its working directory,
but the Agent9 adapter synchronized only generic `input/`, `prompt/`, and
`work/` directories. Runner-owned scenario context therefore did not cross the
Session Drive boundary even though file operations themselves were available.

## Implemented change

Runner-owned Clinic and OP context is stored under the scenario's `context/`
directory, and that exact directory joins the existing synchronized workspace
set. Parent ticket input, sibling scenarios, other runs, and repositories stay
outside the Evidence Agent working directory. Agent9/Codex continues to own
file, shell, code, curl, network, and sandbox policy. The common Clinic Skill
now directs the Evidence Agent to `context/clinic-metrics-context.json` instead
of parent-run `input/` paths that are intentionally outside the role workspace.

## Verification and remaining gap

The post-deployment ST-2865 read-only replay
(`c2b43f87-6f9a-43bd-852a-b56caa8f2543`) completed the Agent9 Router, Evidence
Agent, Scenario Diagnostic Agent, Router reconciliation, and Final Response
chain without the prior Session Drive file-not-found error. A same-Session
probe also read the projected context file successfully.

The bounded runtime defect is deployed and no longer reproduces, but the
problem remains `optimized_unverified`: one managed Clinic request returned
HTTP 422 and the read-only replay did not refresh the mapped Jira internal
comment. The comparison Judge therefore marked semantic convergence and
handoff ownership as met while leaving provider capability inconclusive. The
next validation action is a non-Wetech case with complete provider evidence,
followed by the applicable internal-comment refresh.
