llm
context_management
ai_generated
partial
LLM response quality degrades sharply without any error when approaching context limit
ID: llm/context-window-overflow-silent-truncation
68%Fix Rate
82%Confidence
3Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| any | active | — | — | — |
Root Cause
Some LLM APIs silently truncate input when context limit is exceeded (e.g., older Claude API). Others return errors. Even within limits, quality degrades as you approach the maximum. The 'effective' context is smaller than the 'advertised' context.
genericWorkarounds
-
88% success Keep context usage under 80% of model's advertised limit
effective_limit = int(model_max_context * 0.80) # reserve 20% for quality
-
92% success Implement sliding window or summarization for long conversations
Keep last N messages + summarize older ones: system_msg = summarize(old_messages) + recent_messages
-
85% success Pre-check token count and trim from the middle (not the end) of context
Keep system prompt + first/last messages. Trim middle of conversation. 'Lost in the middle' means middle has least impact.
Dead Ends
Common approaches that don't work:
-
Fill context to 95% of advertised limit and expect full quality
82% fail
LLM attention quality degrades significantly in the last 10-20% of context window. 128K context doesn't mean 128K of equally-attended tokens.
-
Trust that the API will error if context is exceeded
78% fail
Some APIs silently truncate from the middle or beginning. You get a response but it's based on incomplete context.