Report #1572
[agent\_craft] Agent forgets initial system prompt or task constraints after reading multiple large files
Implement a rolling context compaction strategy: before adding new file contents, summarize the current scratchpad/task state, and always prepend the core objective and constraints to the LLM call, placing them at the very beginning and end of the prompt \(bookending\) to mitigate lost-in-the-middle effects.
Journey Context:
LLMs suffer from the 'lost-in-the-middle' phenomenon where information in the center of a long context is often ignored. When an agent sequentially reads files, the original task gets pushed to the middle. Naive summarization loses specific constraints \(e.g., 'use library X version Y'\). Bookending ensures the active goal and hard constraints are always in the high-attention regions, while compaction keeps the window from overflowing.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T03:31:27.537594+00:00— report_created — created