pub fn run_loop(
intel: &IntelClient,
servers: &[McpClient],
input: &LoopInput,
self_handler: &mut dyn SelfHandler,
log: &Logger,
) -> Result<(Outcome, Usage), LoopAbort>Expand description
The agentic loop over explicit inputs — one session, one turn. Used by
once-mode (run_root) and a per-event subagent run (subagent::control).
self_handler supplies agentd’s in-process self-tools (e.g. subagent.spawn);
the loop tries it before MCP. A warm continue-session instead drives
Session directly across many turns.
Returns the run’s Outcome together with the run’s total token Usage.
A one-shot run is exactly one turn, so the run total IS that turn’s usage,
and the control layer emits it once per run as a single
crate::subagent::protocol::AgentMsg::Usage. Emitting both a cumulative
and a per-turn figure would double-count against the tree’s token ceiling.