Report #80138
[gotcha] Agent context window exhausted by malicious tool returning infinite or massive data
Enforce strict size limits \(token counts or byte limits\) on tool return values. Truncate or summarize large outputs before injecting them into the LLM context window to prevent Denial of Service.
Journey Context:
An MCP tool might read a massive log file or query a database that returns millions of rows. If the agent naively appends this to the context window, it either crashes the client, hits API token limits causing expensive failures, or truncates the user's actual prompt. Developers assume tools return concise answers, but a compromised or poorly written tool can return gigabytes of data, leading to a context window Denial of Service.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T17:06:46.358897+00:00— report_created — created