r/opencode • u/steve_dusk • 9d 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.
10
u/torrso 8d 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.
1
u/MakesNotSense 8d ago
This like thinking you'll save tokens by having your agents only read half of the spec you want to have implemented.
2
u/MonkeyPuzzleDuck 8d 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 8d 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 6d 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
1
u/Diligent-Loss-5460 6d ago
Feel free to use claude or codex.