Report #7893
[gotcha] Agent hallucinates or loops repeatedly when reading large files or querying large datasets via MCP tools
Enforce strict max-length limits and pagination on MCP tool return values. Never return raw, massive payloads; always truncate or summarize and include a 'truncated: true' flag in the response.
Journey Context:
When an MCP tool returns a 100k token JSON payload \(e.g., a massive log file\), the orchestrator often silently truncates it to fit the LLM's context window, or the LLM tries to read it, fails to see the end, and calls the tool again in an infinite loop. Developers assume the LLM can 'read' the whole file. The fix is to treat tool outputs as context-expensive and enforce hard limits, forcing the agent to use targeted search tools instead of dumping entire files.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T04:07:28.033488+00:00— report_created — created