# X_AI_CONTEXT_OVERFLOW

## Means

a provider refused a request as longer than the model context window

## Typical cause

a provider answered 400 or 413 with a body saying the prompt outgrew the model's context window (Anthropic 'prompt is too long', OpenAI 'maximum context length', and the other phrases in packages/ai/src/context-overflow.ts). Never retried and never sent to a second provider: the same request overflows every one. agent() compacts once and re-sends before it stops with X_AGENT_CONTEXT_EXHAUSTED; llm() and a direct generate() raise it as itself; terminal for a job

## Fix

`compact: { at: 0.6, keepTurns: 2 }` — on the agent — or shorten the prompt, or route to a model whose registerModel row has a larger contextWindow

[MCP and AI](/error-codes#mcp-and-ai)
