Report #15963
[agent\_craft] Agent enters infinite loop or fails to recover after tool execution errors
Implement the ReAct \(Reasoning \+ Acting\) loop: after every tool execution, inject the result as an "Observation" into the prompt history, force the model to generate a "Thought" analyzing the observation \(including any errors\), and only then permit the next "Action" \(tool call\)
Journey Context:
Simple agents parse tool output once and proceed linearly, missing that tools often return partial errors, rate limits, or unexpected schemas. Without an explicit reasoning step \(Thought\), the model cannot incorporate error information into its next action plan. The ReAct pattern \(Yao et al. 2022\) interleaves reasoning traces with actions, creating a natural breakpoint for error handling. When a tool errors, the Observation contains the error message \(e.g., "Error 429: Rate limit exceeded"\), forcing the LLM to generate a Thought about recovery \(e.g., "I should wait 2s and retry with backoff"\). Without this structure, models either hallucinate success or repeat the failed action indefinitely. The tradeoff is increased token usage \(Thoughts consume tokens\) and latency, but benchmarks show ReAct reduces error cascades by 30% compared to monolithic tool execution.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T01:26:28.538262+00:00— report_created — created