The core agent loop.
Sends messages to a provider, executes tool calls, and loops until the provider signals completion or the turn limit is reached.
This is a pure function — no GenServer, no process overhead.
Summary
Functions
Run the agent loop until completion, error, or max turns.
Functions
@spec run_loop( Alloy.Agent.State.t(), keyword() ) :: Alloy.Agent.State.t()
Run the agent loop until completion, error, or max turns.
Takes an initialized State with messages and returns the
final state with status set to :completed, :error, or :max_turns.
Options
:streaming- boolean, whether to use streaming (default:false):on_chunk- function called for each streamed chunk (default: no-op):on_event- function called with event envelopes:%{v: 1, seq:, correlation_id:, turn:, ts_ms:, event:, payload:}(default: no-op)