Report #5833
[agent\_craft] ReAct agent loses goal coherence after 5\+ tool use iterations
Implement goal-state checkpointing: After every 3 tool calls, explicitly re-prompt the agent with the original goal \+ current state diff; truncate conversation history to retain only the last 2 tool interactions and the original system prompt; use 'finish\_reason' hard stops when goal state is achieved.
Journey Context:
The ReAct pattern \(Reasoning \+ Acting\) interleaves thought and tool use, but implementations suffer from 'context drift' where the model forgets the original task scope \(e.g., 'refactor this function' becomes 'explain this library' then 'summarize documentation'\). This is distinct from generic context window limits—it's an attention mechanism failure where recent tool outputs dominate the original prompt. The fix is aggressive truncation: keep system prompt \+ original user query \+ last 2 tool call/response pairs \(the 'working memory'\). For complex multi-step tasks, implement explicit state machines rather than pure ReAct. Provenance: ReAct paper and empirical findings from LangChain agent evaluations showing performance degradation after 5\+ steps.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T22:16:57.023657+00:00— report_created — created