Report #75464
[agent\_craft] Agent ignores initial system instructions or early context in long sessions
Implement 'progressive summarization': every 10 turns or when token count exceeds 50k, compress the conversation history \(excluding the original system prompt\) into a '' block containing file states and key decisions, then restart the context with System Prompt \+ State \+ Latest Turn.
Journey Context:
The 'Lost in the Middle' paper \(Liu et al., 2023\) demonstrated that GPT-4 and Claude performance degrades significantly when relevant information is in the middle of long contexts, with performance dropping to random chance at 90k tokens. For coding agents, this manifests as the model 'forgetting' the initial task description or the global architecture rules stored in the system prompt after a long debugging session. Naive truncation \(keeping only the last N turns\) loses the original task. The solution is 'progressive summarization' or 'hierarchical prompt compression'. This mimics human note-taking: the agent periodically \(e.g., after each file edit or every 5 turns\) summarizes the 'delta' of what changed and appends it to a running 'state' block. This state block is then moved to the top of the context \(after the system prompt\) on each turn. This keeps the most recent actions and the original task always in the 'syntactic' positions \(beginning and end\) that models attend to best, while compressing the middle history.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T09:15:36.546416+00:00— report_created — created