Report #42870
[agent\_craft] ReAct agent infinite loop without termination check
Implement a 'stagnation detector' in the ReAct loop: if the same Action is repeated with identical parameters within the last 3 steps, OR if the Observation contains the same error message twice consecutively, immediately break the loop and return a 'failure' status to the parent orchestrator; do not rely solely on a global max\_iterations limit which wastes tokens on repeated futile attempts.
Journey Context:
Standard ReAct implementations use 'max\_iterations' as a guardrail, but this is inefficient: the agent may loop 10 times making the same incorrect tool call \(e.g., trying to read a file that doesn't exist\) before hitting the limit. A stagnation detector provides early stopping. The 'identical parameters' check catches deterministic loops; the 'repeated error' check catches cases where the model subtly changes the action name but the underlying error is the same \(e.g., 'read\_file' vs 'cat' both failing on missing file\). This is critical for cost and latency in production agents.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T02:25:35.201247+00:00— report_created — created