Expand description
Tool for calling sub-agents.
The model sees a single subagent_call tool, but the harness dispatches
it to two implementations (see SubAgent): an external agent harness —
driven through the Agent Client Protocol (ACP)
as a full client turn (initialize → session/new or session/resume →
session/prompt), with agent message chunks streamed in real time —
only the LAST message (post-tool-calls) becomes the returned report (see
closure) — or, when agent is omitted/empty, an
internal agent (a nested harness that reports only its final answer).
Two turn behaviors apply to the external path:
- Session resume by default (Phase 4): the agent’s most recent ACP
session is reused on the next call (
continue_session, omitted = resume), keeping the sub-agent’s context across calls;falsestarts a brand-new session. A failed or timed-out turn stores nothing. - Cancellation (Phase 5): the agent loop’s shared stop flag is raced
against the prompt await — a trigger sends
session/canceland the turn ends with the agent’s ownStopReason::Cancelled, preserving the output streamed so far.
§Supported agents
Each agent must speak ACP over stdio — the protocol contract replaces the
fragile per-CLI flag scraping. See acp::ACP_AGENTS for the registry.
Agents without ACP support are not registered.
| Name | ACP invocation |
|---|---|
gemini | gemini --experimental-acp |
goose | goose acp |
opencode | opencode acp |
kilo | kilo acp |
cline | cline --acp |
devin | devin acp |
claude | npx -y @agentclientprotocol/claude-agent-acp@latest (official adapter) |
codex | npx -y @agentclientprotocol/codex-acp@latest (official adapter) |
Re-exports§
pub use types::SubAgentCallInput;pub use types::SubAgentCallOutput;
Modules§
- acp
- ACP (Agent Client Protocol) integration for external sub-agents.
- closure
- The turn’s final-message accumulator: which streamed text is the report
the caller receives (the ACP analogue of the internal harness’s
ContextItem::Closure). Market-standard contract: only the LAST message returns to the parent; earlier narration stays in the live timeline. The turn’s final-message accumulator — the ACP analogue of the internal harness’sContextItem::Closure(the item that marks WHICH text is a loop’s final answer). - events
- Typed event stream mapped from the ACP
session/updatenotifications: the backend foundation for the TUI sub-agent box (Phase 3). Typed event stream for ACP sub-agent sessions. - internal
- Synthesis of typed events for the INTERNAL sub-agent (a nested harness):
maps the nested loop’s plain event stream to the same
events::SubagentEventstream the external ACP path emits, so both sub-agent flavors render identically in the TUI box. Synthesis of typedSubagentEvents for the INTERNAL sub-agent. - sandbox
- Kernel-pinned filesystem sandbox for the ACP
fs/*handlers (Unix only; other platforms use the validate-then-serve fallback inacp). Kernel-pinned filesystem sandbox for the ACP sub-agentfs/*requests (Unix only — see thecfgon themod sandbox;declaration inmod.rs). - severity
- Severity DSL for code-review reports: the
code_reviewprompt contract (<!-- severity: ... -->header) and its extraction. The header tints the sub-agent box green/orange/red (the wire’s middle value stays namedyellow; only the rendered color is orange) and is never rendered. Severity contract for sub-agent code-review reports. - types
- Types for the
subagent.calltool.
Structs§
- SubAgent
- Tool for calling sub-agents.