r/opencode • u/Aquiles_bachira • 22d ago
PSA: Clean your OpenCode database — it might be consuming more tokens than you think
Hey developers!
I've noticed something worth investigating in OpenCode.
The local database and stored session data can grow over time, keeping unnecessary history, messages, and context around. This may contribute to unexpectedly high token usage, especially when working with long-running sessions.
My recommendation:
- Regularly inspect your OpenCode database.
- Clean up unnecessary sessions and stored data.
- Avoid keeping old conversations that you no longer need.
- Monitor token consumption after cleanup.
I think the OpenCode team should also investigate whether database/session management could be optimized to prevent unnecessary context consumption.
Has anyone else noticed unexpectedly high token usage related to OpenCode's stored sessions or database?
Let's discuss this.
14
u/RevolutionaryFunny40 22d ago
other session history should never impact token usage. what evidence or experience do you have that supports this?
6
u/port443 22d ago
I'm a little confused. Are you saying that older session or database data is being sent through in the initial context of new sessions?
How are you checking this?
4
u/Slow-Set-2856 22d ago
It is not loaded in context at all unless you specifically ask to ofc
4
u/bankinu 22d ago
Do you understand what you are talking about?
These doesn't even sound like AI advise, but sure reads like one. Including all the way down to the question mark hook at the end.
Probably you left something out when you summarized. I'd be very curious to know how you reached those conclusions.
2
u/Ribcage84 22d ago
False information it just consimes disk space not token
1
u/megablue 22d ago
wut... old sessions do not actively consuming tokens... unless you chose to resume from those sesisons.
0
u/letuslisp 22d ago
Or start using pi agent harness to get rid of unnecessary tokens.
0
u/[deleted] 22d ago
[deleted] — view deleted comment