kilocode icon indicating copy to clipboard operation
kilocode copied to clipboard

[Bug] Auto-Compaction Repeatedly Fails — "Compaction Exhausted" Error

Open zakimimit opened this issue 7 months ago • 13 comments

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

  1. Start a session in Kilo Code and continue until the context grows large enough to trigger Auto-Compaction

  2. Observe Auto-Compaction starting automatically

  3. Observe the error appearing: Compaction exhausted: context still exceeds model limits after 3 attempts

  4. Observe that the error persists and the session is unable to proceed

Screenshot and/or share link

Image

Operating System

Windows 25h2

Terminal

No response

zakimimit avatar May 01 '26 18:05 zakimimit

@zakimimit - this can happen in two situations:

  1. If you change the model to one with less context size from the one you were using previously
  2. 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 avatar May 02 '26 15:05 lambertjosh

@lambertjosh

  1. I do not change any models. This is the first prompt.
  2. The session does not contain any data, only the first prompt.
  3. I use GLM5.1 and it is from cloud provider

zakimimit avatar May 02 '26 16:05 zakimimit

Simple steps to reproduce:

  1. 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 } } ...

  1. start whatever will consume this, anything like "analyze current files" with something in the folder

  2. observe complete fail of any auto compaction, in contrast, /compact will still work

dmih avatar May 02 '26 16:05 dmih

classification into "extension" may be misleading - this also happens in CLI, no difference

dmih avatar May 04 '26 11:05 dmih

Should be fixed https://github.com/Kilo-Org/kilocode/pull/9887

lambertjosh avatar May 05 '26 13:05 lambertjosh

its not fixed

piottigonzalo avatar Jul 17 '26 16:07 piottigonzalo

@lambertjosh, @alex-alecu I can still reproduce this today on latest build

erwinkramer avatar Aug 30 '26 14:08 erwinkramer

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

dmih avatar Aug 31 '26 16:08 dmih

i have same issues it runs on a loop.

makovez avatar Sep 04 '26 09:09 makovez

@makovez do yourself a favor and try an agent that has a proper core functioning, like pi.dev. Haven't looked back since.

erwinkramer avatar Sep 04 '26 09:09 erwinkramer

#13340 maybe related

rakshith1928 avatar Sep 04 '26 10:09 rakshith1928

@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 avatar Sep 04 '26 17:09 makovez

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

erwinkramer avatar Sep 04 '26 18:09 erwinkramer