Report #67548
[synthesis] Implementing AI agents as unbounded ReAct while loops causes infinite tool-calling cycles and runaway token costs
Architect the agent loop as a finite state machine \(FSM\) with explicit state transitions, forced observation/parsing steps after tool execution, and strict iteration limits per state.
Journey Context:
The ReAct paper popularized the thought-action-observation loop, which most developers implement as a simple \`while True\` loop. In production, this leads to agents getting stuck repeating the same failed tool call. SWE-agent and Devin's observable behavior show they use structured state machines \(e.g., Navigate -> Edit -> Test -> Submit\). By forcing the model to parse the tool output into a specific state before deciding the next action, you prevent the model from ignoring error messages and blindly retrying.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T19:51:46.450057+00:00— report_created — created