Skip to main content

Module protocol

Module protocol 

Source
Expand description

The supervisor↔subagent control protocol. RFC 0005 §control-protocol, RFC 0009 §spawn-payload.

A minimal JSON-RPC sibling — not literal MCP (no initialize handshake) — carried length-framed (4-byte prefix, crate::json::frame) over the child’s stdio pipes, so payloads that contain newlines (instructions, context seeds, distilled results) survive. Two directions: ControlMsg flows down (supervisor→child), AgentMsg flows up.

The control reader inside the child runs on a thread separate from the agentic loop (RFC 0003), so Ping/Pong liveness survives a long in-flight tool/model call. This module is just the wire types; the spawn mechanics are supervisor/spawn.rs, the child side subagent/control.rs.

Structs§

IntelActive
Which endpoint is serving the child’s intelligence, for AgentMsg::IntelHealth. The bounded structural identity ONLY — the list index + the transport scheme (unix/vsock/https) — never the URL/cid/host or any credential (RFC 0012 §3.7, mirroring the agentd://intelligence resource redaction).
IntelConfig
Limits
SeedMessage
A single seed message — a minimal {role, content} pair. Roles mirror the loop’s: system | user | assistant | tool.
SpawnPayload
Everything a subagent needs to run, minted by the supervisor. The child trusts none of this from its own request — depth in particular is minted by the supervisor from the caller’s handle (RFC 0009).
SwapIntel
The intelligence config the child rebuilds its client from on a hot-swap (RFC 0018 §5.2). The endpoint-list URI + the default endpoint-1 credential + the model + the swap policy — exactly the parts IntelConfig carries plus the policy. Boxed in ControlMsg to keep the enum small (like SpawnPayload).
Telemetry
The correlation block stamped into the child’s logs (RFC 0010 §tree-correlation).
TurnResult
A finished turn (RFC 0026 §3.2 step 4). messages is the transcript delta (assistant/tool messages appended during the turn, in order).
TurnSpec
The turn worker’s input (RFC 0026 §3.2). Everything the child needs to run one turn: the system prompt, the context slice, the tool definitions and which of them round-trip, the output schema, and the knobs.

Enums§

AgentMsg
ControlMsg
Role
The child’s role (agentd 2.0, RFC 0026 §2).
TurnKind
What kind of turn a Role::Turn worker runs.

Constants§

ALLOWED_TOOLS_ROLE
The reserved SeedMessage::role that carries a child’s tool allow-listsubagent.run’s tools: narrowing (RFC 0009: scope narrows monotonically down the tree). Minted by the supervisor with SpawnPayload::narrow_tools, enforced by the child in crate::agentloop::runner::Session::prepare, which filters its assembled catalogue AND its dispatch against it.
SUBAGENT_ENV
The environment variable the supervisor sets on the child so its main takes the subagent path instead of re-parsing CLI config.

Functions§

parse_allowed_tools
Parse an allow-list marker’s body (a JSON array of registry patterns: *, an exact name, prefix*). An unreadable body narrows to NOTHING rather than to everything — a grant that cannot be read is not a grant (fail closed).