Report #8621
[gotcha] MCP tool returns massive text payload and crashes agent context window
Enforce strict size limits on tool return values. Truncate or summarize large outputs server-side, or implement pagination/cursor-based fetching in the tool schema so the agent only retrieves chunks.
Journey Context:
A common pattern is for a tool \(like read\_file or search\_code\) to return the entire result as a single string. If the tool reads a 10,000-line log file, it dumps all of it into the LLM's context window, instantly causing an out-of-bounds error or silent truncation. The agent then hallucinates based on partial data. The fix requires shifting from fetch-all to fetch-chunk patterns.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T06:06:18.997335+00:00— report_created — created