[Bug] Auto-Compaction Repeatedly Fails — "Compaction Exhausted" Error
Description
**[Bug] Auto-Compaction Repeatedly Fails — "Compaction Exhausted" Error **
When Auto-Compaction triggers automatically, it consistently fails and displays the following error after exhausting all retry attempts:
Compaction exhausted: context still exceeds model limits after 3 attempts
The error persists across attempts and the compaction process is never able to successfully reduce the context size within the model's limits, effectively blocking the session from continuing.
Expected Behavior
- Auto-Compaction should successfully reduce the context size to fit within the model's limits
- If compaction fails, a graceful fallback or a clear user-actionable message should be provided
- The session should remain usable even if compaction partially fails
Actual Behavior
- Auto-Compaction fails on all 3 attempts
- The error is thrown and persists with no recovery path
- The session is effectively stuck and unusable
- No fallback or helpful guidance is provided to the user
Plugins
No response
Kilo version
7.2.xx
Steps to reproduce
-
Start a session in Kilo Code and continue until the context grows large enough to trigger Auto-Compaction
-
Observe Auto-Compaction starting automatically
-
Observe the error appearing:
Compaction exhausted: context still exceeds model limits after 3 attempts -
Observe that the error persists and the session is unable to proceed
Screenshot and/or share link
Operating System
Windows 25h2
Terminal
No response
@zakimimit - this can happen in two situations:
- If you change the model to one with less context size from the one you were using previously
- In some situations the amount of reserved space is insufficient for the next turn and it overflows the model context window. We need to find these situations and find a way to recover from them.
Could you share session by chance (if it is okay to do so) or by chance just the series of tool calls and their sizes leading up to this, if it is the 2nd bucket?
Also what model are you using and if it's local, did you set the context limit / reserved space?
@lambertjosh
- I do not change any models. This is the first prompt.
- The session does not contain any data, only the first prompt.
- I use GLM5.1 and it is from cloud provider
Simple steps to reproduce:
- add openai-compatable provider with artificial low limits, to get into this faster, as an example:
... "models": { "Qwen/Qwen3.6-27B": { "name": "Qwen/Qwen3.6-27B", "limit": { "context": 40000, "output": 20000 }, "modalities": { "input": ["text", "image"], "output": ["text"] }, "temperature": true } } ...
-
start whatever will consume this, anything like "analyze current files" with something in the folder
-
observe complete fail of any auto compaction, in contrast, /compact will still work
classification into "extension" may be misleading - this also happens in CLI, no difference
Should be fixed https://github.com/Kilo-Org/kilocode/pull/9887
its not fixed
@lambertjosh, @alex-alecu I can still reproduce this today on latest build
this got some regression in latest - appeared a day ago after update; SOMETIMES no compaction is happening at the threshold, seems like limits shifted or some small behaviour change; maybe within documented limits - before today it was indeed sometimes "compacts too early", and now seems more often "too late", maybe just need to adjust the thresholds now; nice if someone talk on the real reason here
i have same issues it runs on a loop.
@makovez do yourself a favor and try an agent that has a proper core functioning, like pi.dev. Haven't looked back since.
#13340 maybe related
@makovez do yourself a favor and try an agent that has a proper core functioning, like pi.dev. Haven't looked back since.
thanks for the suggestions, it's actually better than any I tried. Very fast. I'm using it with 9router and google acc. I wonder if openclaw is better, since it's based on pi
@makovez do yourself a favor and try an agent that has a proper core functioning, like pi.dev. Haven't looked back since.
thanks for the suggestions, it's actually better than any I tried. Very fast. I'm using it with 9router and google acc. I wonder if openclaw is better, since it's based on pi
@makovez you're welcome. OpenClaw is just more opinionated in doing certain use cases and having certain features. It's up to you to extend Pi with more configuration and tools, but you might need less configuration with OpenClaw if it already does what you want, it's just a tradeoff you have to figure out.