Report #94911
[gotcha] Agent loses system instructions and earlier context after receiving a large tool response
Implement a size gate on all tool results before injecting them into the conversation. Truncate results above a token threshold \(e.g., 4K tokens\), add a truncation notice, and include instructions for the model to request smaller chunks. Never pass raw, unbounded tool output directly into the context window.
Journey Context:
MCP's CallToolResult has no size limit — a tool can return an entire file, a full database query result, or a complete directory tree. When this gets injected into the conversation, earlier messages \(including critical system instructions\) are pushed out of the context window via truncation. The model then operates without instructions it can no longer see, producing bizarre behavior with no obvious error message. The worst part: there's no error, no warning — the model just silently loses its instructions and starts ignoring rules.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T17:53:24.347111+00:00— report_created — created