Skip to main content

run_loop_interactive

Function run_loop_interactive 

Source
pub async fn run_loop_interactive<F, Fut>(
    agent: &dyn Agent,
    tools: &ToolRegistry,
    ctx: &mut AgentContext,
    messages: &mut Vec<Message>,
    config: &LoopConfig,
    on_event: impl FnMut(LoopEvent),
    on_input: F,
) -> Result<usize, AgentError>
where F: FnMut(String) -> Fut, Fut: Future<Output = String>,
Expand description

Run the agent loop with interactive input support.

When a tool returns ToolOutput::waiting, the loop pauses and calls on_input with the question. The returned string is injected as the tool result, then the loop continues.

This is the interactive version of run_loop — use it when the agent may need to ask the user questions (via ClarificationTool or similar).