Skip to main content

Module control

Module control 

Source
Expand description

The subagent side of the control channel.

Entered when main sees AGENT_SUBAGENT set. The child, in order:

  1. installs PR_SET_PDEATHSIG so a supervisor death collapses it. This must happen here rather than in pre_exec, because execve clears the setting;
  2. reads its SpawnPayload (first control frame) from stdin;
  3. starts a control reader thread, separate from the agentic loop, that answers Ping with Pong and flips a cancel flag on Cancel, so liveness survives a long in-flight tool or model call;
  4. emits Ready, connects intelligence + its scoped MCP servers, runs agentloop::run_loop, and sends Result/Failed back up.

Wire: stdout carries length-framed AgentMsg up; stderr carries the child’s JSON telemetry (inherited to the parent). stdin carries ControlMsg down.

Functions§

run
The subagent entry point. Returns the process exit code.