Expand description
Generic agent loop — drives agent + tools until completion or limit.
Includes 3-tier loop detection (exact signature, tool name frequency, output stagnation). Features from Claude Code (HitCC analysis):
- Tool result pairing repair — ensures every tool_use has a matching tool_result
- Context modifiers — tools can adjust runtime behavior via ToolOutput::modifier
- Max output tokens recovery — auto-continuation when response is truncated
Structs§
- Loop
Config - Loop configuration.
Enums§
- Loop
Event - Events emitted during the agent loop.
Functions§
- ensure_
tool_ result_ pairing - Ensure every tool_use in messages has a matching tool_result, and vice versa.
- run_
loop - Run the agent loop: decide → execute tools → feed results → repeat.
- run_
loop_ interactive - Core agent loop — single implementation for both interactive and non-interactive modes.