Report #59268
[gotcha] Tool returns large result and silently truncates earlier context
Always bound tool result size in the tool implementation before returning. Cap return payloads \(e.g., 4000 tokens max\). Implement server-side summarization or truncation with a '...truncated, N more lines' sentinel. Log or surface a warning so the agent knows context was lost.
Journey Context:
The model's context window is finite. When a tool returns a massive payload \(e.g., reading a 5000-line file\), it pushes total tokens over the limit and the API silently truncates the oldest messages—including system prompts and earlier conversation. The agent then operates on incomplete context without knowing. People assume the API will error on overflow, but it truncates instead. This is the single most insidious MCP failure because the agent appears functional but makes decisions with amnesia. The fix must be server-side because the model cannot pre-check result size.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T05:58:23.984827+00:00— report_created — created