kilocode icon indicating copy to clipboard operation
kilocode copied to clipboard

compaction strategy/experience is horrible

Open HugoCatarin0 opened this issue 7 months ago • 13 comments

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

HugoCatarin0 avatar Apr 25 '26 09:04 HugoCatarin0

Compaction exhausted: context still exceeds model limits after 3 attempts { "name": "ContextOverflowError", "data": { "message": "Compaction exhausted: context still exceeds model limits after 3 attempts" } }

fxcl avatar Apr 28 '26 15:04 fxcl

+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).

dmih avatar Apr 28 '26 16:04 dmih

+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

SilentDemonSD avatar May 01 '26 16:05 SilentDemonSD

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:

Image

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.

rkfg avatar May 15 '26 10:05 rkfg

@tkfg. Does not make any difference. I can see plenty of context left on llamacpp side. Its something wrong with Kilo

AkikoOrenji avatar May 22 '26 03:05 AkikoOrenji

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.

dmih avatar May 22 '26 18:05 dmih

@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.

rkfg avatar May 23 '26 10:05 rkfg

I also raised the same issues #12124 and #12196 with automatic/manual compaction not working, but they have not been resolved yet.

hi-one-gg avatar Jul 14 '26 05:07 hi-one-gg

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 the id of 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_id after this row, including it.
  • Write Changes. Reload your conversation, the compaction loop should be gone.
  • REMEMBER TO BACK UP KILO.DB!

YukinoHayakawa avatar Jul 18 '26 20:07 YukinoHayakawa

i have same issues it runs on a loop.

makovez avatar Sep 04 '26 09:09 makovez

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

rakshith1928 avatar Sep 04 '26 09:09 rakshith1928

Improved by fixes in commit 9be7edfe62:

  1. Early auto-compaction is fixed — compaction now triggers at the configured threshold, not ~27k tokens early (due to double-counting system prompt + tool schemas).
  2. Models without a configured context window no longer trigger one-summary-call-per-message chunking.
  3. Interrupted compactions are properly settled, preventing repeat loops.
  4. 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.

HenricHuntsman avatar Oct 27 '26 12:10 HenricHuntsman

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

Nomadu27 avatar Oct 27 '26 20:10 Nomadu27