Expand description
The core agent execution loop.
run_fighter_loop is the heart of the Punch runtime. It orchestrates the
conversation between the user, the LLM, and the tools (moves), persisting
messages to the memory substrate and enforcing loop guards.
§Production features
- Context window management: Tracks estimated token count and trims messages when approaching the context limit.
- Session repair: Fixes orphaned tool results, empty messages, duplicate results, and missing results on startup and after errors.
- Error recovery: Handles empty responses, MaxTokens continuation, and per-tool timeouts.
- Loop guard: Graduated response (Allow → Warn → Block → CircuitBreak) with ping-pong detection and poll-tool relaxation.
Structs§
- Fighter
Loop Params - Parameters for the fighter loop.
- Fighter
Loop Result - Result of a completed fighter loop run.
Functions§
- run_
fighter_ loop - Run the fighter loop: the core agent execution engine.