The actor turn loop
One queued input produces one complete turn:
- Append or deduplicate
InputQueuedusing its UUID command ID. - Activate the actor if it is idle.
- Select the oldest unhandled input and append
TurnStarted. - Assemble context and call the provider.
- Validate and authorize tool calls, then start accepted calls together.
- Append tool progress and results in execution order while returning results to the model in call order.
- Append exactly one terminal event: completed, failed, cancelled, or interrupted.
- Drain the next input or become idle.
Streamed text, reasoning, and tool-call deltas are durable before publication. Sync tools use worker threads; async tools stay on the event loop. A failed tool call becomes that call’s error result and does not cancel siblings.
Inputs received during a turn remain FIFO and never steer the active sample. Cancellation targets the live root tree and queued work; a later root command can activate the root again.