run_agent

Function run_agent 

Source
pub async fn run_agent(
    agent_ref: AgentRef,
    task: AgentTask,
    tx: UnboundedSender<AgentEvent>,
) -> Result<AgentRunHandle, AgentError>
Expand description

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.

Working directory resolution:

  • agent_ref.working_directory if non-empty
  • else the current process working directory

Identity / memory bundle resolution and named-agent continuation are NOT plumbed in Phase 1.5 PR 2 — the drone Agent block always spawns fresh (per spec §8 “drone runs always allocate fresh instance_name”). The bundles can be added in a follow-up once the drone inspector (PR 3) needs to surface them.