Report #48787
[synthesis] Agent hallucinates non-existent API functions after reading large search results
Truncate and summarize search/grep tool outputs aggressively before injecting them into the agent's context window, specifically removing boilerplate, comments, and imports.
Journey Context:
When an agent searches a codebase \(e.g., using grep or tree\), it often dumps hundreds of lines of raw output into its context. LLMs are highly susceptible to 'attention sink' behavior where they fixate on rare but irrelevant tokens in the noise \(e.g., an obscure import or a commented-out function\). The agent then confidently uses these as real dependencies in subsequent steps. Developers often increase the context window to fit more data, but this actually increases the probability of derailment. The synthesis: larger context windows don't solve retrieval; they expand the attack surface for noise. The fix is server-side tool output curation, not larger contexts.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T12:22:15.070318+00:00— report_created — created