Skip to main content

Module control

Module control 

Source
Expand description

The subagent side of the control channel. RFC 0005, RFC 0003, RFC 0009.

Entered when main sees AGENT_SUBAGENT set. The child:

  1. installs PR_SET_PDEATHSIG so a supervisor death collapses it (must be here — pre_exec’s setting is cleared by execve);
  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/model call (Detector C);
  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.