Add the capability route matrix: tool calls through Code Mode, `ToolBridge`, `BackgroundTools`, sub-agents and UI round trips match the native typed history
Stacked on #14366. Not tied to a closing issue: this is contract C1 of the capability conformance plan, toward #13118 (no capability content below 'operator' in system voice).
C1, the route matrix. tests/harness/test_capability_routes.py runs each case's calls with every capability it builds lowered to with_authority('none'), once natively and once through each route:
- Code Mode, IPython Code Mode and
ToolBridge: each call is made fromrun_codeortool_call, unless the route keeps that tool native; BackgroundTools(tools='all'): each call runs as a background task;- a sub-agent, given the capabilities through
SubAgents(shared_capabilities=...); - a
PrepareToolshook that builds each tool definition anew, leaving out the ids the framework stamps; - a
ModelMessagesTypeAdapterdump and load; - a Vercel AI and an AG-UI run with
manage_message_history='server', followed by a second run where the client sends the whole conversation back.
What it compares: typed history, not wire text. What a call returns travels in a carrier of the route's own (the run_code result, a background result), so the check compares everything else the calls add to the history: each part's type, source, capability id, authority and frame must equal the native route's. The same tools must run, too, so a route that never makes a call can't pass. Two PROBES give every route a part to compare, since few cases' calls produce one: a tool that returns ToolReturn.content, and one that calls ctx.enqueue.
Known findings are strict xfails (KNOWN, with what fixes each), so each fix fails the suite until its entry is removed:
ToolReturn.contentthrough Code Mode, IPython Code Mode andToolBridgeā #14327.BackgroundToolskeeps the frame ofToolReturn.contentbut drops the capability that wrote it (_format_background_result) ā #12391.Planningfinds a plan tool's result only in that tool's ownToolReturnPart. After a plan tool runs through Code Mode, IPython Code Mode orBackgroundTools, it records the plan again in a<plan_reminder>ā #14441.
The prepare hook that rebuilt ToolDefinition and dropped capability_id was fixed by #14374, so its entries are gone and that route now passes for every case.
Counts (locally; BrowserUse isn't installed here): 45 subjects (43 cases with calls, plus 2 probes) Ć 9 routes. 384 pass, 7 are strict xfails, and 16 are skipped: 10 for BrowserUse not being installed, and 6 where the route keeps every tool the calls make native (Shell and the tool_kind tools under ToolBridge). The IPython route shares one kernel per module (per xdist worker). The module runs in about 15s on 8 workers.
Not covered here: Temporal and DBOS are durable routes, which D1 covers per case, as the checklist says.
Wiring:
agent_docs/capability-conformance.md: C1 is no longer "planned". It names the test and says how to add a route.DECLARES_CALLS:BackgroundTools,CodeMode,IPythonCodeModeandToolBridgeare no longerPENDING_CALLS, since C1 runs every case's calls through them.test_pending_calls_backfilldrops from 15 to 11.ToolSearchstays pending.tests/append_only.py:_run_through_uibecomesrun_through_ui, andOneCallPerResponse,build_callsandas_capabilitiesare shared by the contracts suite and the route matrix, so both drive a case'scallsthe same way. The durable suite keeps its ownone_call_per_responseandbuild_caseintests/harness/_durable_cases.py: it needs an unstreamed model that counts unprompted requests, and a build under the case'senv.
Checklist
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
- PR title is fit for the release changelog.
š¤ Generated with Claude Code
Summary by cubic
Adds C1, the route matrix: every capability case's calls now run at with_authority('none') natively and through every route a tool call can take, and the typed history must match the native route's.
tests/harness/test_capability_routes.py compares the parts the calls add to history ā type, source, capability id, authority, frame, scope, and for the probes content ā across Code Mode, IPython Code Mode, ToolBridge, BackgroundTools, a sub-agent, a prepare hook that rebuilds tool definitions (preserving ui_visibility), a ModelMessagesTypeAdapter round trip on the native run, and Vercel AI and AG-UI runs with server-held history. Return values are excluded, since each route carries them its own way. Three PROBES ensure every route has a part to compare: one returns ToolReturn.content, one calls ctx.enqueue with text, and one enqueues a request-scoped instruction, so a route that turns a request-scoped part into a lasting one fails too. The same tools must run, so a route that never makes a call can't pass.
Known findings are strict xfails, so each fix fails the suite until its entry is removed:
ToolReturn.contentthrough Code Mode, IPython Code Mode, andToolBridgeā #14327.BackgroundToolskeeps the frame ofToolReturn.contentbut drops the capability that wrote it ā #12391.Planningrecords a plan again in a<plan_reminder>after a plan tool runs through Code Mode, IPython Code Mode, orBackgroundToolsā #14441.
C1 is marked implemented in agent_docs/capability-conformance.md, _run_through_ui became run_through_ui, and BackgroundTools, CodeMode, IPythonCodeMode, and ToolBridge no longer count among the pending calls backfill cases (15 to 11), leaving ToolSearch pending. The count is pinned: changes that affect it must lower it in the same change. OneCallPerResponse, build_calls, and as_capabilities now drive a case's calls the same way across the contracts, route matrix, and durable tool IO suites, and the contracts suite runs through the shared model and builder. Durable routes (Temporal, DBOS) stay D1's.