llm
context_management
ai_generated
true
Input silently truncated — total tokens exceed model context window
ID: llm/token-limit-silent-input-truncation
88%Fix Rate
90%Confidence
4Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| any | active | — | — | — |
Root Cause
Some APIs silently truncate input that exceeds the context window.
genericWorkarounds
-
92% success Count tokens with tiktoken before sending and chunk within limits
import tiktoken; enc = tiktoken.encoding_for_model('gpt-4'); len(enc.encode(text))Sources: https://github.com/openai/tiktoken
-
85% success Use a sliding window or map-reduce pattern for long documents
Split into overlapping chunks, process each, then combine
Sources: https://python.langchain.com/docs/how_to/summarize_stuff/
Dead Ends
Common approaches that don't work:
-
Just increase max_tokens parameter
90% fail
max_tokens controls output length, not input
-
Split input into multiple sequential API calls
70% fail
Sequential calls do not share context