Report #75738
[agent\_craft] Agent context window fills up and naive truncation \(dropping oldest messages\) loses critical system state or user requirements
Implement sliding window with 'anchor' preservation: always keep the system prompt, the most recent N turns \(e.g., 3\), and any messages containing tool results marked as 'critical' \(e.g., error states or user confirmations\); summarize evicted middle turns into a rolling summary statement
Journey Context:
Simple 'drop oldest' truncation breaks agents because early messages often contain persistent requirements \(e.g., 'Use Python 3.9 syntax'\). The 'anchor' pattern treats the context as a ring buffer with protected frames at the start \(system prompt\) and end \(recent turns\), summarizing or dropping the middle. This is related to the MemGPT approach but lighter weight. The key insight is that tool error states must be preserved as 'anchor' events because the model needs to know it failed recently to avoid retry loops. This pattern is documented in OpenAI's agent guides and the 'Message Management' sections of various agent frameworks.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T09:43:35.295992+00:00— report_created — created