Skip to main content

Module subagent

Module subagent 

Source
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; false starts 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/cancel and the turn ends with the agent’s own StopReason::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.

NameACP invocation
geminigemini --experimental-acp
goosegoose acp
opencodeopencode acp
kilokilo acp
clinecline --acp
devindevin acp
claudenpx -y @agentclientprotocol/claude-agent-acp@latest (official adapter)
codexnpx -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’s ContextItem::Closure (the item that marks WHICH text is a loop’s final answer).
events
Typed event stream mapped from the ACP session/update notifications: 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::SubagentEvent stream the external ACP path emits, so both sub-agent flavors render identically in the TUI box. Synthesis of typed SubagentEvents 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 in acp). Kernel-pinned filesystem sandbox for the ACP sub-agent fs/* requests (Unix only — see the cfg on the mod sandbox; declaration in mod.rs).
severity
Severity DSL for code-review reports: the code_review prompt contract (<!-- severity: ... --> header) and its extraction. The header tints the sub-agent box green/orange/red (the wire’s middle value stays named yellow; only the rendered color is orange) and is never rendered. Severity contract for sub-agent code-review reports.
types
Types for the subagent.call tool.

Structs§

SubAgent
Tool for calling sub-agents.