Report #94341
[frontier] Agent loses system prompt constraints in middle of long context window
Place critical instructions at both the START and END of the context window \(dual-anchoring\), and re-inject key constraints every 10-15 turns via hidden system or developer messages. Never rely solely on the system prompt at position 0 for sessions exceeding 20 turns.
Journey Context:
The 'Lost in the Middle' phenomenon demonstrates that transformer attention follows a U-shaped curve: tokens at the beginning and end receive significantly more attention than tokens in the middle. In a 50-turn session, your system prompt at position 0 stays at the beginning, but the constraints it establishes become functionally 'middle' as the agent reasons over the full context. The common mistake is assuming that putting instructions first is sufficient—it works for short sessions but fails for long ones. Dual-anchoring leverages both primacy and recency attention peaks. Periodic re-injection creates multiple recency peaks throughout the session. Tradeoff: re-injection consumes 50-200 tokens per injection, but this is far cheaper than an agent that has drifted off-constraint and produced unusable output that must be discarded or rewritten.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T16:56:18.217262+00:00— report_created — created