Skip to main content

Module runner

Module runner 

Source
Expand description

Unified agent runner — one-shot Claude Code spawn for the drone Agent block.

Spawns claude --print --output-format=stream-json as a non- interactive subprocess, drains its stdout through ClaudeTranslator, forwards each AgentEvent on the caller’s tx, and resolves the handle’s final_result with the structured AgentRunResult once the stream emits Done.

Headless and one-shot by design — the drone Agent block’s contract is “send task, wait for done, return result.” The interactive agent pane has its own PTY-based controller in blockcontroller/shell/lifecycle.rs; that path is NOT routed through this runner’s spawn — what’s shared is the translator + event shape, not the spawn function. (This used to cite a SPEC_UNIFIED_AGENT_TYPES spec that no longer exists anywhere in docs/; the pointer was dropped rather than replaced — see scripts/check-spec-citations.sh.) It DOES reuse this module’s commit-aware admission gate (admit_spawn / agent_commit_reserve_gb, pub(crate)) — see blockcontroller::shell::lifecycle::ShellController::start, which calls them right before spawning a claude/codex/ gemini/qwen interactive pane, mirroring this file’s run_agent gate.

Structs§

AgentRunHandle
Handle returned by run_agent. The caller already holds the mpsc::UnboundedReceiver<AgentEvent> they paired with the tx passed into run_agent; this handle adds the structured terminal value via final_result (drone Agent block’s downstream output).

Enums§

AgentError
Error returned by the runner.

Functions§

run_agent
Spawn claude --print --output-format=stream-json per the given AgentTask and AgentRef, drain its stdout through the shared ClaudeTranslator, forward each AgentEvent on tx, and resolve the returned handle’s final_result with an AgentRunResult constructed from the terminal Cost + Done events.