I've been using OpenCode from time to time for about a month, mainly working on a single side project in a tiny VPS. The disk free space is getting less and less so I decided to do some cleanup, then this caught my eye:
$ ls -lh ~/.local/share/opencode/opencode.db
-rw-r--r-- 1 ubuntu ubuntu 2.4G Apr 15 03:25 opencode.db
One month, non-heavy usage, single project, 2.4 GB of session database. That seems crazy.
What's eating the space
I asked an agent to give me more background and it turns out, OpenCode stores the full thinking & reasoning output for every turn in a single SQLite database. In my case, most of my 2.4 GB database is reasoning tokens and tool results, only less than 1% is actual conversation text. I'm not sure what's the real value of keeping them all, especially in a single SQLite database (credit to the strong SQLite), and I'm surprised to see OpenCode has no built-in cleanup for this. So this will just keep growing forever, until it becomes a black hole larger than node_modules.
For reference, Claude Code stores 86 MB for the same period. Codex uses 95 MB.
Let's garbage collect OpenCode session database
So I ( actually claude code ) built ocgc (OpenCode Garbage Collector).
uv tool install ocgc
ocgc status tells you where the space goes:
ocgc analyze shows your heaviest sessions and how fast the database is growing:
For the actual garbage collect part, ocgc purge:
ocgc purge --subagents --older-than 7d
809 sessions, 1.8 GB. Gone. Then ocgc vacuum to actually reclaim the disk space, from 2.3 GB down to 438 MB.
After cleaning up the database, I also noticed OpenCode's snapshot/ and session_diff/ directories can take up quite some space too, so ocgc cleans those as well.
Go check your ~/.local/share/opencode/opencode.db. Disk space doesn't grow on trees.



Top comments (0)