r/ClaudeCode • • 3h ago

Tips & Workflows PSA: Auto-compaction is a huge source of Claude gaslighting you

Idle compaction silently drops any constraints and guidelines you spent establishing over the course of the chat/project then Claude carries on confidently as if it still knows the assignment and bulldozes you. If you’ve ever been gaslit by an Anthropic model is this why. Disable this “feature” if you find yourself constantly arguing with the model.

53 Upvotes

43 comments sorted by

•

u/AutoModerator 3h ago

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

28

u/muhuhaha 2h ago edited 1h ago

As others mentioned the goal, for me at least, is to avoid compacting all together, and also avoid the cache expiring (for newer users, basically if you reply quickly it uses a lot less tokens, if you don't reply for roughly an hour or more, it uses 10x the tokens same amount of tokens but equivalent of 10x more against your usage limit).

My limiting factor to how many sessions i open at once is if I can reply to them in time before cache expires basically. If they get long or im leaving for a while or I'm just worn out, I just ask them to "prep handoff so we can continue in fresh session". Then just start a fresh one and say "lets pickup where we left off". Happy to answer questions for any newer users, I can no longer tell whats obvious or confusing anymore, I promise not to tell you quit claude code and kill yourself hah

4

u/kdubsjr 1h ago

Does it use 10x the tokens or does the cost of the tokens just increase 10x

7

u/muhuhaha 1h ago

Thanks for asking, i knew answer (same number of tokens, but cost of tokens goes up) but in finding details for my reply i was shocked by how much of a difference, here's what claude says:

Say your conversation is 300k tokens and you send one more message.

Cache still warm: the 300k is read from cache at 1/10th price, so it counts like about 30k tokens.

Cache expired: the 300k is re-read at full price and cached again at a small premium, so it counts like 375k–600k tokens (375k with the 5-minute cache, 600k with the 1-hour one).

Same 300k tokens either way, but the expired one costs 12–20x more. If input costs $5 per million tokens, that's about $0.15 against $1.90–$3.00 for a single message. Do that across a few long sessions and you can see why people race the cache.

and here's even more detail if interested:

It's the same number of tokens; what changes is the price. Each time you send a message, Claude re-reads the whole conversation. If that conversation is still cached, the re-read is billed at about 1/10th of the normal input price. The cache only lasts a while (5 minutes or an hour, depending on your setup). Once it expires, the next message re-reads everything at full price, plus a small extra charge to cache it again. So a reply after the cache expires costs roughly 10x more, even though the token count is identical. On a subscription, that cost is what eats into your usage limits.

3

u/hi_im_leffe 1h ago

Ask Claude to setup a cron heartbeat and your cache will never expire.

2

u/fschwiet 1h ago

Thanks for posting this, I'm surprised by the 5-minute cache I thought there was only a 1 hour cache.

1

u/muhuhaha 1h ago

I didnt know either, mines about 1 hour so must be some setting i forgot about, assuming 5 minute one is meant for automated things

2

u/fschwiet 1h ago

Looking into this, on subscription plans claude code defaults to using the 1 hour cache for the main session but may use the 5 minute cache for subagents and background tasks.

My first read missed that its going to use one or the other, so treating claude CLI like it has a 1 hour cache was appropriate.

1

u/muhuhaha 1h ago

I also just now realized i totally missed your point, I edited my reply to fix that sentence, thanks!

1

u/story_of_the_beer 1h ago

What not ask claude to write an auto cache warmer hook? This is especially great at a 5min TTL as reading the warm cache saves you even more at that threshold. I prefer 1h TTL tho as it's easier to juggle multiple agents and even several autowarms beats cold cache hits. Can even ask claude to tune how long your auto warmer should be based on your habits.

1

u/muhuhaha 1h ago

I've heard of that but wasnt sure if against TOS, also if I normally take like 10-30 minuts to reply to a session, would the 5min TTL mean your heartbeat would be sending entire context (at cached rates) every 5 min while waiting for you me to reply? I have a lazy version right now where i just type "ping" in a session i want to keep cache warm and it replies "pong" hah

1

u/Active-Season5521 1h ago

I would just make it 55 mins to catch the biggest hit, so you aren't burning tokens all the way up

9

u/Inner_Storage_3374 2h ago

what helps is keeping the rules in CLAUDE.md instead of the chat. afaik that file gets loaded again after compaction, while stuff you agreed on 2 hours ago in the conversation is a summary line at best. so whenever you catch yourself repeating a constraint, thats the moment to move it into the file

4

u/Dorbank_Justt 2h ago

Per the docs, what gets lost is anything you only said in chat. On compaction the conversation is summarized, but the project-root CLAUDE.md is re-read from disk and re-injected. Nested CLAUDE.md files and rules with paths: frontmatter get summarized away too, and load again when Claude next reads, writes or edits their trigger file. So constraints you can't afford to lose belong in the root CLAUDE.md. To stop the idle pass itself, set "idleCompaction": false in settings or change the Idle compaction row in /config.

2

u/fschwiet 1h ago

Are you also setting your autocompact to 1 million? It was recently changed to 400k.

2

u/momentum77 16m ago

I keep an orchestrator running long term by asking it for a clean compaction prompt. I do this around 400k and 500k context usage. All the sessions it manages are fresh as needed for each task, be they builders or qas or reviewers or planners or documentaries or roadmap maintainers. All those specialists get recycled, but my Prime holds it together tightly

9

u/jd52wtf 3h ago

If your sessions are compacting you aren't properly chunking your projects.

7

u/wittycrow8073 3h ago

i just raw dog days of work through vs code and its fine tbh.

7

u/TaiChuanDoAddct 2h ago

I've done it both ways and find they work equally well/poorly depending my degree of effort and split attention.

They have different failure modes and friction points but I i dont think either is a clear winner.

1

u/wittycrow8073 2h ago

100%. The one thing i did was turn off idle compaction because it was annoying.

2

u/markedness 4m ago

All these problems I don’t have…

And hell ill compact if im pounding thru a long trouble shooting session with tcpdump and it accidentally cats out 10,000 packet summaries if im on a roll… but yeah for development no and never seems to be an issue in the first place.

Also when will Claude figure this out. Or is it good for business to just let it rip?

Or is there some reason models aren’t aware of or can’t see into their own context rot

2

u/Aggravating-You8299 2h ago

chunking works until you hit a messy refactor that spans ten files, then youre burning tokens just re-explaining the architecture every time you start a fresh session

2

u/under_psychoanalyzer 31m ago

Well then you should be documenting your architecture better. 

2

u/elgarduque 20m ago

Wait, we're supposed to be documenting? 

1

u/fschwiet 1h ago

Claude recently updated the default compaction trigger to 400k instead of 1 million. I rarely get to 400k breaking things up. Do you think I should keep the limit at 1 million? I have the same view, if compaction runs I am doing something wrong.

2

u/hi_im_leffe 3h ago

So setup a hook that uses /compact keep: and have Claude identify what should he kept in context as he's working at what token level you want, I recommend 300k.

Have fun.

1

u/duboispourlhiver 3h ago

Good answer! Also you can add to system prompt, it gets reinjected after compaction

1

u/TinFoilHat_69 25m ago

I do that with codex using Luna 6 on max saving lots of token usage with hook injections, it’s on par with 5.6 sol

1

u/Suitable_Cicada_3336 26m ago

Even you don't use auto compacted, claude still cheat at auto missions. 3rd party llm check and fight is necessary.

0

u/akienm 1h ago

Huh. Is that an observation or is that documented somewhere? Because I would say that my observations are the opposite. When we got all of the state data out of the context and onto the disk, the problem went away. And the auto compact now has no effect on the operations.

0

u/EndlessZone123 41m ago

Why is your constraints or guidelines not in a Agents or claude.md? Compaction and chat history is for context. User messages are usually quoted verbatim in the compaction and agents can search compacted history when needed. Seems like user error for me. Or Te your agent to always remember these and write them in the instruction file.

0

u/tehfrod 22m ago

This word you keep using... I do not think it means what you think it means.

-9

u/pceimpulsive 3h ago

My question for those impacted by this is why are you leaving sessions open long enough to need an auto compact... Stop being shit and learn to manage the context better.

9

u/ajax81 3h ago

I know you’re trying to be helpful but that tone undermines you.

You want your guidance and advice to resonate and reflect well on you, right?

7

u/PsychoticDreemurr 3h ago

The context can easily be filled halfway within a hour. Less, if you're not offloading the work onto subagents properly.

If you're doing any actually large project that uses several workflows and subagents at any given moment, the context isn't nearly as large as you think it is.

1

u/pceimpulsive 3h ago

I'm working on a 3 year old project if I loaded the entire thing into context it would easily eat the entire thing and be compacted multiple times...

My agents never do that... A project from a week or two ago involved 1 orchestrator, 20-50 sub-agents, my orchestrator was a bit over 250k by the end..

The session all up was about $250-350 USD at API rates on opus 5.5 medium. one sub agents was dished far far too much work and hit 450k I handed off it's work and split it up, that split resulted in 7 more sub-agents doing targeted work.

2

u/PsychoticDreemurr 1h ago

How is your orchestrator moving information from, to, and between its subagents? Even with workflows and scripts basic information logistics eats up my context like nothing

Also side question, is there a specific methodology you're using to divide work?

2

u/ContextLengthMatters 3h ago

I honestly haven't considered context in the past 6 months. Anyting I need to do with tight constraints is done on the first few turns and the rest is just whatever.

Compacting is fine enough for the majority of work where you jump around in a project. I'm too lazy to care about clearing context for the most part because I get the output I expect with the way I interface with the model.

1

u/Ai-ate-my-hamster 3h ago

Ironic username?

2

u/ContextLengthMatters 3h ago

Nope. Context length definitely matters, especially when using local AI. However, compaction isn't really an issue these days. For instance going back and forth with a code review and going through multiple parts of the code, I really don't care when and how it compacts. It's rather seamless.

I also don't care when I'm brainstorming. It only ever matters when you have very specific usecases that make context drift ruin your session (roleplay). I don't really care about that.

That's not to say I don't ever get into issues where I need to clear my session because my context is poisoned by something, but that's about it. If my session runs long, it's because I don't really care about tight constraints, otherwise I'd try to build a handoff prompt to oneshot it somewhere else.

It possibly helps that I also have my AI keep a running summary of what I care about if I go multiple turns. I will always tell it to reiterate where we are at in a conversation if I want to keep things in context.

1

u/ralfonso_solandro 1h ago

Relevant username?

1

u/pceimpulsive 3h ago

So in one session you work the UI, the API the database and logging?

That's a recipe for context rot big time.

I engineer my context in the form of new sessions and keeping each session on a tight leash topic/codebase area wise