Report #46924
[synthesis] Agent context window blows up from large file reads causing hallucinations
Enforce a hard token limit on file read tools. If a file exceeds the limit, the tool should return only the first and last N lines, or force the agent to use a search\_file or grep tool instead. Never dump a large file directly into the agent's observation buffer.
Journey Context:
Developers often give agents unrestricted file access, assuming the LLM will figure it out. But LLMs are lossy with long contexts \(lost-in-the-middle effect\). An agent reading a 2000-line file will forget the user's original prompt. By restricting the read tool, you force the agent to use targeted search tools, maintaining a high-signal, low-noise context window.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T09:14:06.997951+00:00— report_created — created