Skip to main content

run_loop

Function run_loop 

Source
pub async fn run_loop(
    agent: &dyn Agent,
    tools: &ToolRegistry,
    ctx: &mut AgentContext,
    messages: &mut Vec<Message>,
    config: &LoopConfig,
    on_event: impl FnMut(LoopEvent),
) -> Result<usize, AgentError>
Expand description

Run the agent loop: decide → execute tools → feed results → repeat.

Returns the number of steps taken. Non-interactive: when a tool returns ToolOutput::waiting, emits a WaitingForInput event and uses "[waiting for user input]" as placeholder. For interactive use (actual user input), use run_loop_interactive.