r/opencode • u/steve_dusk • 19d ago
Opencode 2 consumes more $ than opencode 1
Hello, I've upgraded to opencode 2, its pretty good, except for one major issue, I cant compact multiple times, if the context reaches 300k+, I compact it, the context disappears but its not a low number, then I continue coding, and it shows up at around ~90k, and I cant compact again because theres nothing to compact.
This was a nice feature in opencode 1, that I could compact multiple times, all the way until it reached 1-2k context only, and this decreased the $ the models were burning, but now that I cant compact multiple times, I cant reduce back the $ usage to a lower number.
1
u/MakesNotSense 19d ago
This like thinking you'll save tokens by having your agents only read half of the spec you want to have implemented.
1
u/steve_dusk 18d ago
I'm not "thinking" it saves tokens, I know it uses less $, each time with 200k+ context it can use .10$ or significantly more for even medium/smaller tasks, but starting a new one costs about .01$ to read context, and .02-.05$ to finish it. So not always but usually cuts the expense in half or less.
1
u/MakesNotSense 18d ago
An agents 5k tokens summary built to replace a 200k token range of messages will require more than 5k tokens to rebuild from an empty context window.
The immediate cost after compaction doesn't tell you how many tokens the agent had to burn to rebuild the understanding it needed to continue working.
It doesn't tell you if the quality of its work output dropped because the information it needed to work competently was destroyed by compaction.
This is like firing a senior engineer and claiming it reduces costs because you don't have to pay their salary anymore, while ignoring how expensive it is to operate without their experience and expertise. You essentially downgrade your agent to a junior with each aggressive compaction.
1
u/steve_dusk 17d ago
I understand what youre saying, but each and everytime the context got destroyed, it continued EXACTLY where it left off, thats exactly the reason I made the post, I havent noticed a single difference between having 300k context vs 1.7k after multiple compaction, the AI model operated the EXACT same way, no difference, havent lost any details, it continued exactly where we left off, AND it was cheaper, thats the whole point.
1
u/steve_dusk 17d ago
This just tells you that it highly depends on the model, I just know that DS v4.1 would have been hallucinating after multiple compactions.
1
u/MakesNotSense 17d ago
If what you work on is so low complexity that aggressive compaction works without noticeable degradation, Okay then. For demanding tasks compacting like that would delay work and increase token usage per task while degrading work output.
1
u/steve_dusk 17d ago
Well, not always, it ranges from low complexity to more complex and even longer tasks, I'm using GLM 5.3 Flash, and I noticed that it follows my ~3k .md rules files without issues, no other model followed guidelines so well. So, could just be a GLM thing.
1
u/MakesNotSense 17d ago
I would say, GLM 5.3 flash while generally capable, can't handle high complexity work.
I've built a very specialized opencode fork harness focused on agents curating their own context and persisting state across sessions and developing protocols for system prompts and skills in order to improve task performance.
That work was done because I'm working on very complex problems that typically take teams of highly competent professionals from multiple disciplines working in an interdisciplinary manner (e.g. complex civil rights litigation).
Opus 5.5 with all the harness and tool supports we've made still ends up making significant errors simply because the harness supports aren't adequate to let it keep up with the demands. This type of task work doesn't get done without context staying at around 200k-400k on a constant basis (I don't use compaction, but context management). Session starts are around 70k tokens, containing project history, prompts, necessary skills.
I don't use compaction before it's inferior to context management. Compaction used aggressively compounds it's defects. It would make this type of complex work impossible. Agents would make more mistakes that compound and create cascading failures.
The limits of frontier models are easier to find in this type of demanding work. Find the limitations, model the failure mode, then build supports, and agents can then work past where people think the frontier is.
I would suggest your compact habit is limiting your agents. They can't manifest new capabilities via emergent complexity, because you keep them at their baseline model capabilities.
Capabilities can be encoded into model parameters via training, or encoded into system prompts, skills, or project state entries (a memory system).
1
u/steve_dusk 17d ago
Well I wouldn't say GLM 5.3 Flash is really capable, because its not the strongest model of all time, obviously since its just the flash version of 5.3, but even the 5.3 is not the most capable. But it does really well for its price, exceptionally well.
And probably for the work youre doing, its clearly not enough, I've used Sonnet 5, so not opus 5.5, and it made multiple errors and didnt always follow instructions/guidelines, while GLM 5.3 flash did.
I have multiple files that even tell the AI model how to indent the SCSS code, with 2 spaces to make the code look compact, and it has to mirror the HTML structure, so nest it. This is just one small instruction, I have an Agents.md, rules.md backend-skill.md & frontend-skill.md, these all together are around 3-4k lines of text.
And GLM follows them stupidly good, what I noticed is that I just tell it what to do, even bigger tasks, it creates 50 files, finishes, I check the files, and I dont have to ask to edit like 95% of them, they all basically look exactly how I imagined. Its rare that I have to tell it to check the modified files and make sure to align them to the .md files.
So, for my use case its really good. And yeah obviously these tasks use more context, like 300k+, it wouldnt make sense to stop it halfway through to compact, I dont do that, I only compact it when it finishes, and its high.
2
u/MonkeyPuzzleDuck 19d ago
Slightly off topic, but also related, have you tried tokless?
https://github.com/HoangP8/tokless
I work primarily with charities and non-profits where keeping costs down is a real concern. I've found this plugin, which wires together several tools, to be be quiet effective. I've not used it enough to conclusively say it works as advertised, but promising so far.
1
u/thevegit0 19d ago
i think long chats are still cheaper due the read cache, THERE are some models that cost more with more context, be sure to check https://opencode.ai/v2/docs/console/go
1
u/Chromedomev12 16d ago
well apparently they support background compaction now as an experimental feature. You can enable it with a config change I think. https://opencode.ai/v2/docs/compaction/#background-compaction
10
u/torrso 19d ago
You're optimizing for the wrong thing. Compaction isn't free. It uses the LLM to process and summarize the conversation, consuming tokens in the process. And every compaction is lossy, so repeatedly compacting an already compacted context just keeps throwing away potentially useful information.
With prompt caching, continuing with a large context can actually be cheaper than repeatedly compacting it.
And what exactly do you expect a coding agent to accomplish with 1–2k tokens of conversation history? That's potentially already less than the system prompt. You've effectively wiped out everything it learned about the task, the decisions it made, and the problems it encountered and maybe there's a bug in v1 that even compacted the system prompt? At that point, why not just start a fresh session?
Compaction has its uses, but obsessively reducing the context to the smallest possible size is a terrible optimization strategy. The goal should be to minimize the cost of successfully completing a task, not the number of tokens in the context window.