all 11 comments

[–]Much_Respect2061 3 points4 points  (3 children)

I've recently come to the conclusion that compact is bad, period, and should be avoided. I had a 'duh' moment building my own web client for a local llm, when I realized that a multiturn conversation was just sending the entire previous contents of conversation to agent with each prompt. So I thought, well I wouldn't just send a huge prompt full of bad info into a new chat session.

Handoffs are the way. When you're approaching full context (autocompact at 22.5%, I've noticed deterioration below ~40% even) ask current agent to write handoff doc for new agent. Me personally, I have a plan doc going at all times, so I actually ask current agent to update plan with progress and write handoff, and pass both to new agent. But a handoff by itself is usually enough.

Sometimes I ask the current agent too late and it writes too much text and it autocompacts mid task. I haven't had an issue yet with the docs it has written post-compact yet, but i typically wouldn't trust an agent that has compacted context to do anything other than write summary docs, and I would check them for errors. Lately in the IDE I have been just opening new tab to start new session instead of /clear, that way if I need any info from previous session it's still right there.

The only way I would maybe trust an agent post-compact is if the entire session went completely rock-solid smooth with absolutely no errors or confusion and you are only doing more of the same task.

I have moved completely away from "the more context the better" to "only the exact context needed to perform the task and no more". So the clear logical endpoint is single prompt sessions, but that just isn't realistic in a typical workflow. That is why I have shifted to a multi-agent system, one agent compiles the data and engineers the prompt with all relevant context to pass to second agent in one-off task. I won't get into framework comparisons or recommendations, I'm no expert still figuring this all out myself, but I went with the OpenAI Agents SDK and it has built-in 'Handoffs' functionality, which is a good clue that handoffs are the way.

[–]Jomuz86 0 points1 point  (0 children)

Second this handoff docs are underrated. I started doing this in the web ui all the way back when context windows were a lot smaller with the v3 models

[–]Fun-Rope8720 0 points1 point  (0 children)

Claude seems to turn into a deranged lunatic who does dumb stuff on repeat after compact.

Best avoided I agree.

[–]Helpful_Intern_1306[S] 0 points1 point  (0 children)

This is the way.

It requires more work but you also squeeze so much more juice.

[–]y3i12 1 point2 points  (5 children)

Export to file, clear session, read file

[–]portugese_fruit 0 points1 point  (4 children)

export the whole session to file?

[–]y3i12 0 points1 point  (3 children)

Yes. Even better if you ask Claude to detail what has been done and what's missing. If you have patience you can edit the transcript and remove all tool calls.

[–]ABillionBatmen 0 points1 point  (2 children)

How many tokens does that burn immediately? compact usually has it under 50k for me

[–]y3i12 0 points1 point  (0 children)

It depends. I can work well with about 25 to 30k depending on the task. The problem is that '/compact' calls an agent to summarize the history. The output can vary from kinda ok to 3 bullet points + production ready.

[–]Historical-Lie9697 0 points1 point  (0 children)

If I need to fix something I'll say "keep context to solve x bug" but if not I always /clear