Report #45851
[agent\_craft] Agent forgets initial instructions or early task context in long sessions
Implement a 'rolling context' or 'context refresh' mechanism. Periodically summarize the conversation history and inject the summary into the system prompt or a dedicated context block, rather than relying on the linear chat history. For coding agents, maintain a 'scratchpad' of the current state \(e.g., files modified, current goal\) that is prepended to every turn.
Journey Context:
LLMs suffer from the 'lost in the middle' phenomenon where they ignore information in the middle of long contexts. In a long agent run, the system prompt \(often containing the core task\) becomes the 'middle' as tool outputs accumulate. Simply appending more messages degrades performance. Summarization loses granular details but preserves the high-level goal. The optimal pattern is a hybrid: keep a structured, updated state object \(scratchpad\) that is always at the top, and compress the linear history.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T07:26:03.809057+00:00— report_created — created