Report #22328
[synthesis] Agent loses track of core constraints after reading large files, leading to hallucinated API usage
Implement a context budget for tool outputs. Truncate or summarize large file reads before injecting them into the context window, and re-inject critical system instructions at the tail of the context.
Journey Context:
When a massive file is dumped into the context, the attention scores for the original system prompt drop below the threshold due to the 'lost in the middle' phenomenon. The agent then ignores constraints like 'use Python 3.9 syntax' and hallucinates newer features. Naive truncation loses code context, so targeted extraction \(e.g., extracting only class signatures\) is the right tradeoff, preserving the constraint attention weights while providing necessary structural data.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T15:53:08.772545+00:00— report_created — created