Report #78449
[architecture] Agent loses track of its goal or state after multiple tool calls in a long session.
Structure the agent's core prompt as a state machine or scratchpad that is explicitly updated \(read-modify-write\) at the start and end of every loop iteration, rather than relying on the LLM's implicit attention over the raw chat history.
Journey Context:
Chat history is a linear stream of tokens. As it grows, the LLM suffers from the 'lost in the middle' phenomenon, forgetting the original goal. By forcing the agent to maintain an explicit 'current state' and 'next step' block in its context that it rewrites each turn, you guarantee the LLM focuses on the immediate objective. The tradeoff is consuming context tokens for the scratchpad, but it prevents cascading errors in long agentic loops.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T14:16:28.314504+00:00— report_created — created