Claude API context window exceeded errors spike
product-rca case · difficulty 4/5 · 20 minutes · software-tech · Anthropic
Prompt
You are a product manager at Anthropic. Enterprise API 'Context Window Exceeded' errors spiked 300%. Find out why.
Context
The API returns a 'context window exceeded' error when the total input tokens exceed the model's limit of 200,000. The error rate across enterprise requests went from about 0.30% to about 1.20% over nine days. Work the problem as a root-cause analysis: define the metric, structure hypotheses, slice the data, pin the cause, then fix and prevent.
Clarifying questions
- Did users upload larger files? Did the limit change?
- The model's context limit did not change, and the typical size of uploaded documents is the same.
- Is it spread across customers?
- The increase appears concentrated in a small number of API keys, but we have not looked at what they have in common.
Recommendation
**Root cause:** A popular third-party LangChain integration updated its default retrieval chunk size, silently bloating context payloads so that about a fifth of requests on the affected keys exceeded the 200,000-token window. - **Evidence:** 12 keys account for all of the increase, all use integration v0.9 (v0.8 is unaffected), retrieved context tripled from 40,000 to 120,000 tokens with the same number of chunks, and pinning the older version removes the errors. - **Fix now:** Contact the 12 customers and the integration's maintainers: tell them to set the chunk size explicitly or pin v0.8, and ask for a patch release that restores the default or documents it. - **Prevent:** Return token counts and a breakdown in the error message, add a token-count preview endpoint, alert by key when average payload size jumps and track SDK and integration version telemetry. - **Track:** Average token payload, Error rate by API key, SDK version telemetry
Risks
- Telemetry on third-party integrations is limited, so other affected customers may remain unnoticed
- Truncating context automatically could silently degrade answer quality
Next steps
- Notify all customers using v0.9 and verify the fix with the 12 keys
- Track average token payload, error rate by API key and integration version