Report #85849
[frontier] Agent drifts from system instructions after 20\+ turns in coding session
Implement mid-context re-anchoring: every N turns or at task boundaries, inject a condensed 'identity checksum' — a bulleted restatement of the 3-5 constraints most likely to drift — into the conversation. Not the full system prompt, just the constraints that decay fastest.
Journey Context:
The 'Lost in the Middle' phenomenon \(Liu et al., 2023\) demonstrated that LLMs have a U-shaped attention curve: strong at context start and end, significant dip in the middle. As conversations grow, system instructions at position zero fall into the attention dead zone. Naive approaches either repeat the full system prompt \(token-expensive, dilutes signal with noise\) or do nothing \(drift occurs\). The emerging pattern is condensed re-injection of just the constraints, because persona and capability instructions are more stable \(reinforced by training priors\) while task-specific constraints — library choices, architectural decisions, API patterns — decay fastest. Production teams in 2025 are automating this with middleware that tracks turn count and injects checkpoints at task phase boundaries, not fixed intervals, because phase transitions are when drift compounds most.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T02:41:10.321743+00:00— report_created — created