Execution loop
Main requests, worker tasks, and result collection share the same execution machinery.
One cycle
The captured settings and tool router govern both the model request and its tool calls. A tool result becomes input to the next step. Turns continue until completion, failure, interruption, or an explicitly configured step limit.
Progress and committed history
Text streams to the browser while the response is arriving. Core validates the complete response before executing its requested tools, then records history and publishes lifecycle events. Partial streamed text is provisional.
Input and failure
Next-step input steers an active turn. Next-turn input waits in the browser until the conversation is idle. Agent messages are read at step boundaries and do not start an idle conversation.
Tool errors return to the model as results it can act on. Provider failures end the turn while retaining completed steps and tool effects. Child interruption cancels execution and preserves history for later reuse.
Implementation: session/turn.rs.