Skip to main content

Module agent_loop

Module agent_loop 

Source
Expand description

Shared agent loop for tool-calling models.

Used by non-interactive mode (SilentObserver), sub-agents (SubagentObserver), and the TUI (TuiObserver). The observer pattern lets each consumer plug in its own model-call and subagent- handling strategies: the default trait methods do simple sync/join work (good for non-interactive and subagents); the TUI overrides call_model and run_subagents to drive channel-based streaming and live rendering without forking the core loop.

The trait is Send-bounded so futures returned by its default methods are Send (required by tokio::spawn in subagent code). The TUI observer is also Send: it holds &mut Terminal<...> and &mut App, both of which are Send since io::Stdout and the tokio sync primitives inside App are Send.

Structs§

AgentLoopResult
Result of running the agent loop
ModelCallOutput
Output of a single model call, returned from the call_model hook.
ToolExecutionResult
Result of a single tool execution

Enums§

LoopControl
Control flow for the agent loop

Constants§

MAX_AGENT_ITERATIONS
Default maximum iterations for the agent loop

Traits§

AgentObserver
How the agent loop communicates with its environment.

Functions§

run_agent_loop
Run the agent loop: execute tool calls, feed results back, repeat.