Skip to main content

run_agent_loop_with_config

Function run_agent_loop_with_config 

Source
pub async fn run_agent_loop_with_config(
    session: &mut Session,
    initial_message: String,
    event_tx: Sender<AgentEvent>,
    llm: Arc<dyn LLMProvider>,
    tools: Arc<dyn ToolExecutor>,
    cancel_token: CancellationToken,
    config: AgentLoopConfig,
) -> Result<()>
Expand description

Runs the agent loop with a custom configuration.

This is the primary entry point for executing an agent conversation loop. It manages LLM streaming, tool execution, task list tracking, metrics collection, and event emission throughout the conversation lifecycle.

§Arguments

  • session - The conversation session to operate on
  • initial_message - The user’s initial message to process
  • event_tx - Channel sender for agent events
  • llm - The LLM provider to use for generation
  • tools - The tool executor for handling tool calls
  • cancel_token - Token for cancelling the operation
  • config - Configuration controlling loop behavior

§Returns

Returns Ok(()) on successful completion, or an error if the loop fails.