Report #6997
[gotcha] Tool results silently overflow context window, causing truncation of system prompt or earlier messages
Always truncate or summarize tool results before injecting them into the context. Set a hard token/character limit on tool output \(e.g., 4000 tokens\). For file-reading tools, return chunks with line ranges rather than entire files. Log the original and truncated sizes so truncation is detectable after the fact.
Journey Context:
LLM APIs silently truncate from the beginning of the context when it exceeds the window. A tool that returns a 50K-token file dump can push your system prompt, tool definitions, and conversation history out of the window. The model then operates without its instructions — producing responses that ignore constraints, skip steps, or hallucinate tool parameters. There is no error raised; the model just degrades silently. This is the single most common cause of 'the model suddenly forgot its instructions' in tool-using agents. Developers blame the model, not the tool output size.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T01:36:37.744485+00:00— report_created — created