A failed 'compact' operation should not clear the chat.
To upvote this issue, give it a thumbs up. See this list for the most upvoted issues.
Describe the bug When the context window is (almost) full and the compact operation fails (e.g., due to size constraints), the system still clears the existing context as if the operation succeeded. This bug prevents users from attempting a more minimalistic summarization or other corrective actions on the original context, resulting in data loss.
Expected behavior
Clear the context only when the /compact is successful.
@zikajk do you have a visual example or something with what you mean with "failed"? I'm not sure how to handle this fail, but I want to understand better when that happens
Hello @ericdallo this is the first time I used compact and I tried it multiple times with multiple models, it fails every time. This is with latest version of emacs package and on latest eca version 0.78.4
That's weird, what model are you using?
gpt-5, gpt-5-mini, gpt-5-nano. I switch between these models.
Here is the thing,
I hit the token limit with gpt-5, so I try to compact with gpt-5-nano or gpt-5-mini as they have higher token limits in my subscription, I get the error in the screenshot above.
now when I stop eca and create a new new eca session, work for 5 minutes and run compact, it works as expected with any of these models. Weird.
I looked at the logs and I do not see any errors.
Is there an option to automatically run compact when we breach certain limit in context token threshold?
Is there an option to automatically run compact when we breach certain limit in context token threshold?
No but that may be the thing that we need to avoid those issues, Check #116
@CsBigDataHub would be great, the problem is that the number of tokens reported in ECA isn't always correct and forcing compact too soon might be frustrating. It is hard to deal with every model and caching. I think that supporting '/undo' would be simplest solution to this problem right now.
We can discuss in #116 but I think having a % configurable by user would probably be enough: user can configure 10% or 20% to auto compact.
Micro-compact is different. It just remove old tool calls from the history to save some context. But I am afraid that CC use Haiku for it to analyze what is good to remove and what not :-(. I will try to find more info and add it to that ticket.
What I noticed is that when I use sonnet-4.5 via GitHub, window gets full when I see something like this in Eca 170K/120K or 140k/120k. So with this model I would configure it to be 110% :-).
Micro-compact is different. It just remove old tool calls from the history to save some context. But I am afraid that CC use Haiku for it to analyze what is good to remove and what not :-(. I will try to find more info and add it to that ticket.
So maybe we should have a different issue: Auto-compact
What I noticed is that when I use sonnet-4.5 via GitHub, window gets full when I see something like this in Eca 170K/120K or 140k/120k. So with this model I would configure it to be 110% :-).
That's weird indeed, please open a new one for this specific case so we can make tokens usage precise
Same here, I'm using claude opus 4.5 and when I hit the limit (eca failing due to to big context), I went to /compact and it wiped the history and compacted to empty message.
Ok, I think I fixed the corner cases:
- when you stop the prompt
- when API returns any errors
I don't think /compact should fail anymore, but LMK otherwise