Summary
Starting an agent hands the caller a stream, a raw cancellation channel, and a piece of shared mutable state to read usage out of, and the run is identified by an HTTP request id threaded into every call. On top of that, one component parks that id on itself as mutable state, so a single MCP manager can serve only one run at a time. Replace the entry point with a handle that owns the run.
Goals
- One handle owning a run's event stream, its cancellation, and its usage, in place of a tuple and out-of-band state.
- Run identity carried in scope wherever code runs inside the run, rather than every component holding its own copy.
- One cancellation mechanism. Two exist today — a watch channel and a cancellation token — and the agent implementations do not agree on which they honour.
- Hooks a genuine extension point rather than one implementation doing several unrelated jobs.
Additional Context
Two things run outside anything the agent can scope, and both need identity delivered to them rather than reading it.
Rig executes tools on a long-lived server task of its own, so a tool call cannot see the run it belongs to. MCP clients are therefore bound to the run they serve, which is the same shape as the ambient state this replaces: safe while a manager serves one run at a time, and a race the moment one is shared. Warm MCP reuse in #578 needs that resolved, by per-run tool instances or a rig-side change, and this does not resolve it.
Progress notifications arrive on the transport's task for the same reason and are correlated by their call's progress token.
The turn-depth nudge stays a tool wrapper. It works by appending text to tool output so the model reads it as the next turn's prompt, and rig's hook surface takes the prompt immutably with no point at which a hook can contribute to a turn. Expressing it as a hook needs a rig-side change — the fork already carries a StreamingPromptHook fix — rather than shaping the hook trait around this one feature.
Searched Issues
Code of Conduct
Summary
Starting an agent hands the caller a stream, a raw cancellation channel, and a piece of shared mutable state to read usage out of, and the run is identified by an HTTP request id threaded into every call. On top of that, one component parks that id on itself as mutable state, so a single MCP manager can serve only one run at a time. Replace the entry point with a handle that owns the run.
Goals
Additional Context
Two things run outside anything the agent can scope, and both need identity delivered to them rather than reading it.
Rig executes tools on a long-lived server task of its own, so a tool call cannot see the run it belongs to. MCP clients are therefore bound to the run they serve, which is the same shape as the ambient state this replaces: safe while a manager serves one run at a time, and a race the moment one is shared. Warm MCP reuse in #578 needs that resolved, by per-run tool instances or a rig-side change, and this does not resolve it.
Progress notifications arrive on the transport's task for the same reason and are correlated by their call's progress token.
The turn-depth nudge stays a tool wrapper. It works by appending text to tool output so the model reads it as the next turn's prompt, and rig's hook surface takes the prompt immutably with no point at which a hook can contribute to a turn. Expressing it as a hook needs a rig-side change — the fork already carries a
StreamingPromptHookfix — rather than shaping the hook trait around this one feature.Searched Issues
Code of Conduct