Return value of run_loop: the stop reason plus the two input channels
that were lent in, handed back so messages queued but never drained (e.g. a
follow-up sent while the loop was on its final turn) survive the run
boundary instead of being dropped when the caller re-pairs channels.
Cap on consecutive turns that ended in a fed-back stream error. A
transient-class stream failure no longer kills the run — the loop feeds the
error back to the model and retries the turn — but a persistently broken
request (or a model that cannot recover) must still terminate. After this
many consecutive fed-back error turns the run ends with StopReason::Error
exactly as it did before. Any turn that completes cleanly resets the count.
Default per-run turn cap for LoopConfig::max_turns. Generous enough for
long agentic tasks, low enough that a runaway tool loop can’t burn tokens
unbounded. Unlike cancellation, hitting it is a clean, resumable stop.