compaction strategy/experience is horrible
Description
while using a small token window model e.g. groq gpt oss 120b, I would expect kilo to still handle properly compaction..
unfortunately I keep getting errors like:
Compaction exhausted: context still exceeds model limits after 3 attempts{ "name": "ContextOverflowError", "data": { "message": "Compaction exhausted: context still exceeds model limits after 3 attempts" } }
Plugins
No response
Kilo version
No response
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response
Compaction exhausted: context still exceeds model limits after 3 attempts { "name": "ContextOverflowError", "data": { "message": "Compaction exhausted: context still exceeds model limits after 3 attempts" } }
+1
auto-compaction is plain not working at all right now; no matter what settings we try, it ends up with this "after 3 attemps" without any real actual attempts (this message is displayed immediately and without any LLM call).
right after that, you can /compact and it will mostly work (mostly because there are a lot of other tickets about that it just ruins the chat and no of any use, but that's another story, here we at least need it to start happening).
+1
It's causing a serious issue for low comtext model or any model switch when context window is changed, all the context goes to waste, make a new chat and loop continues, instead use some sort of graphical memory so that it can have persistent memory and context
Idk why this is not in the main options but you can explicitly set the context size and max output tokens (output) in the config like this:
You can set the context to a slightly lower number to trigger compaction earlier and still have some space for the compaction system prompt and output.
@tkfg. Does not make any difference. I can see plenty of context left on llamacpp side. Its something wrong with Kilo
I am watching a lot of compaction issues and I might say that all of them are really fixed now, except on documentation side. There were many of them, most on "... failed after 3 attempts", and now it is working. It is a pity, however, that for most of the people, it takes literally hours and days to find this config with limits and it's syntax, at last. It is a pity that OpenCode has VERY limited documentation on providers, and Kilo has ZERO of it.
@tkfg. Does not make any difference. I can see plenty of context left on llamacpp side. Its something wrong with Kilo
Not sure what you mean. If the setting is in effect you'll see your context occupation in percents and if that setting is missing or not applied it will be in raw tokens. Make sure to restart VS Code or reload the current window.
I also raised the same issues #12124 and #12196 with automatic/manual compaction not working, but they have not been resolved yet.
Not only Compaction exhausted, there is another annoying bug where:
- A model with smaller hit context limit.
- Kilo enters compaction loop.
- You try to change to a model with larger context, hoping it could stop.
- Nope. It still tries to compact the session non-stop and just won't succeed no matter what, basically preventing you from using the conversation.
However, I found a temp fix for this problem:
- Get DB Browser for SQLite
- Open
~\.local\share\kilo\kilo.db - Go to Browse Data -> Table
session, find theidof your conversation. - Go to Table
part, filter using your session id. - You will see something like
{"type":"compaction","auto":true,"overflow":true,"tail_start_id":"msg_xxx"} - This is the message causing Kilo to get stuck in the compaction loop.
- DELETE rows for your
session_idafter this row, including it. - Write Changes. Reload your conversation, the compaction loop should be gone.
- REMEMBER TO BACK UP KILO.DB!
i have same issues it runs on a loop.
Yes small context windows suffer because auto compaction trigger too early,i had tested it with a 1M context window model setting threshold percent at 10 and it kept on looping at the start of session, this pr likely solves it.https://github.com/Kilo-Org/kilocode/pull/13340
Improved by fixes in commit 9be7edfe62:
- Early auto-compaction is fixed — compaction now triggers at the configured threshold, not ~27k tokens early (due to double-counting system prompt + tool schemas).
- Models without a configured context window no longer trigger one-summary-call-per-message chunking.
- Interrupted compactions are properly settled, preventing repeat loops.
- Only consecutive compactions (with no completed step between) count toward the exhaustion cap.
However, the broader compaction experience improvements (e.g. #15049 for sub-agent task preservation) are tracked separately.
On the persistent-memory request in this thread: disclosure, I make Sigillion, memory for coding agents, so compaction and model switches don't cost you earlier work. Claude Code only today; more agent tools are planned for the end of 2026. https://github.com/Sigillion-AI/sigillion