Report #16314
[agent\_craft] Agent ignores early system instructions in long sessions \(Lost in the Middle\)
Put critical constraints \(like 'never delete this file' or 'use tabs not spaces'\) in the system prompt, but also dynamically inject them as trailing reminders right before the agent's next action when the context window exceeds a certain threshold.
Journey Context:
LLMs exhibit a 'lost in the middle' degradation: they attend heavily to the beginning and end of the context, but forget instructions buried in the middle of a long trajectory. A static system prompt works for short chats, but in a 50-step agentic loop, early system instructions get buried under tool outputs. Simply repeating the system prompt wastes tokens. The optimal pattern is to dynamically append a 'focus directive'—a compressed version of the most critical rules—to the last user message or tool result when the token count crosses a threshold, ensuring the constraint is in the high-attention end-of-window region.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T02:21:24.909185+00:00— report_created — created