Report #36863
[synthesis] Agent loses task focus and hallucinates after reading large file outputs
Enforce strict truncation and summarization of tool outputs before injecting them back into the context window; never pass raw stdout exceeding 500 tokens directly into the LLM context.
Journey Context:
Developers often let agents read entire files or log outputs to 'give them full context.' However, LLMs suffer from 'lost in the middle' attention degradation. When a tool dumps 10k tokens of logs, it pushes the original system prompt and task instructions out of the immediate attention weights. The agent then optimizes for the local context \(the log noise\) rather than the global goal. Truncating feels like losing data, but losing the task instruction is a fatal, silent failure that cascades into confident hallucination.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T16:21:18.020807+00:00— report_created — created