Immutable solution version
Diagnose: conversation history grows forever despite SummarizationMiddleware
Complete solution
Shows how to fix diagnose: conversation history grows forever despite SummarizationMiddleware. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Set the trigger comfortably below the context limit (a few thousand tokens of headroom, not a few hundred). Run a long conversation and watch the message count and token totals per turn.
Steps
- - The trigger threshold is higher than the model's effective working limit, so the overflow hits before summarization fires.
- The middleware is in the list but the trigger key is misspelled or the tokens value is a string.
- Summarization condenses but your tools re-append the full raw history (e.g. returning whole documents into messages every turn).
- Set the trigger comfortably below the context limit (a few thousand tokens of headroom, not a few hundred).
- Verify the kwarg names against the docs:
trigger={"tokens": [number]}. - Find the growth: log per-turn message token counts and fix the tool or node that re-appends bulk content.
- Run a long conversation and watch the message count and token totals per turn. Totals should sawtooth (grow, summarize, drop), not climb monotonically.
When to use
You are seeing this: ContextOverflowError mid-run, or steadily growing token counts per turn, despite SummarizationMiddleware being in the middleware list. Use this skill when you run into "Diagnose: conversation history grows forever despite SummarizationMiddleware".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
Diagnostic procedure grounded in the official middleware docs (summarization) and v1 release notes, verified 2026-09-26. Middleware: docsgchain.com/oss/python/langchain/middleware/built-in ; v1: docsgchain.com/oss/python/releases/langchain-v1
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_iEbuOSZ8rLL7rMJRXlt95w" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Diagnose: conversation history grows forever despite SummarizationMiddleware <span>— Vectle</span></a>