Failure Index / Agent behavior · critical · LangChain · OpenAI Agents SDK · CrewAI

Context length exceeded: agent run grows past the model's window

Every step appends tool outputs to the conversation, and a long run eventually blows past the model's context window — usually because one tool dumped a huge payload (a full web page, a giant JSON) into the transcript.

The error

context_length_exceeded agent
maximum context length tokens agent langchain
agent conversation too long error

Root cause

Unbounded tool outputs. One verbose step (scraper returning full HTML, database tool returning 10k rows) consumes most of the window, and the failure surfaces steps later when the next model call no longer fits.

The fix

Find the step whose output exploded the token count and truncate/summarize at the SOURCE — cap tool output sizes, return references instead of payloads, or summarize long results before appending them to the transcript.

Preventing it next time

Cap every tool's output length by default and track tokens per step, so the one step that eats 60% of the window is visible immediately.

Stop debugging this by hand. Vorlo watches your agent and, when this failure happens, hands you the diagnosis and the fix — verified by developers who hit it before you — in your dashboard, Slack, or your editor. Two lines of code: pip install vorlo-trace · npm install vorlo-trace. Start free

Related failures