Symptom
A later turn raises BadRequestError with context_length_exceeded. The message in the report is This model's maximum context length is 128000 tokens. However, your messages resulted in 142800 tokens (142586 in the messages, 214 in the functions).
Evidence what you'll see
- The traceback is in
acall_modelwhile streaming acreate_react_agentgraph that usesAsyncPostgresSaver. - The maintainer comment on 6 Mar 2025 says this is a model context-window limit, not a langgraph or checkpointer bug.
Why it happens
Tool messages from the retriever stay in the checkpointed history, so each turn sends a longer transcript. The model rejects the request when that transcript passes its context limit.
Affected versions
langgraph 0.2.58, langgraph-checkpoint-postgres 2.0.15, langchain 0.3.11, langchain-community 0.3.11. The linked issue does not name an operating system.
Fix steps
0 of 2 done
Your check marks stay in this browser only.
How to check it worked
- A later turn on the same thread no longer raises
BadRequestErrorforcontext_length_exceeded.
If it still fails
- The linked issue does not include a library patch. It was closed completed because the maintainer classed it as a context limit. The stored checkpoint still holds the old tool messages until the history is trimmed.
Sources and credit
Summarized in our own words from these public reports. Credit goes to their authors.
Provided as is, without warranty. Try changes in a non-production environment and back up first. Security-related steps: verify against the official docs. Terms · Request removal or attribution change
Hit an error we don't cover? Submit it