Implement ai.external: ExternalHarness, ExternalHarnessProvider and Session #346
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 406 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.359
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #346"
general
weight: 0.35
1st1
A draft for
ai.external. #347, the competing draft, is closed.An external harness is a coding-agent CLI (Codex, Claude Code, Pi, fx) where a model goes. It has the shape of an
ai.Model: plain data and a provider. The state is in a session.ExternalHarness: the settings of the CLI. It holds no state.ExternalHarnessProvider:name,executable,env, and thestream()thatai.streamandai.Agent.runcall.Session: the state (id,messages) and direct control (start,send,events,interrupt,close).Sessions
async with harness.session()is the only way to start the CLI. A model call outside the block raisesExternalHarnessError. No call starts a CLI for one turn.harness.session()is a new session.harness.session(session_id)continues one that the CLI has, andharness.session(messages=history)starts one with a past (lossy). To continue later, savesession.idwith the harness data.harness.session()in the block raises. Two tasks can each open one.session.start()starts the CLI early in an open block. It does not open a session.Compared with #347
ai.streamstill callsmodel.provider.stream(model, ...); the diff outsideai/externalisModel->ModelLikeannotations, oneaclosingblock inapi.py, theContext.modelannotation, and the two protocols (ModelLike,ProviderLike) inmodels/core/model.py.ai/__init__.pyimportsexternal, as it doesdurableandtesting.hooks.pyis as onmain.Session, not on the harness.output_type,fork()andsync().fx
ai.external.Fxdrivesfx acp(Agent Client Protocol over stdio). The wire follows Codex;JsonRpcPeermoved toexternal/_jsonrpc.pyso that both use it.model_providerandeffort. fx runs with--permission-mode full-access.session/load. If fx refuses it, the wire removes what it wrote and raisesExternalHarnessErrorwith the fx version.Fx: a bridge tool must answer in 5 minutes; streamed tool results are short previews; instructions are fixed when the session starts; the built-in tools cannot be limited. The store format is internal to fx, so a new fx release can break the seed.Session.interrupt()does nothing between the end of a turn and the start of the turn that fx makes from a late steer. After an interrupt, a steer that fx dropped goes again as a new prompt.Status
src tests) and ty pass locally and in CI (Python 3.12 to 3.14) on0073da8.AI_EXTERNAL_LIVE=1 uv run pytest tests/external/test_live.py) were not run after the session changes (d0dffe8and later). The last recorded run is fx only, with fx 0.0.17 on57bd861.