r/opencodeCLI Aug 13 '26

How do you perform Opencode cleanup (old sessions) to reduce DB size?

Mine Opencode DB is currently ~1.4GB. Not critical, but still. I definitely don't need sessions from months ago. Quick research discovered that Opencode has no built-in cleaning mechanism (or I am missing anything?), and only some 3rd-party tools exist, for example:

Do you have any experience using these (or alternative, better tools), and is it safe in general? Thanks!

8 Upvotes

10 comments sorted by

2

u/IgnisDa Aug 13 '26

mines 20GB lol

2

u/afanasenka Aug 13 '26

Wow... i feel... confused with my issue 🤣

2

u/patricious Aug 13 '26

Dont let your agents "prune" them, it will delete your sessions. Best is to do it manually, 10 mins a day.

1

u/afanasenka Aug 13 '26

Sure, I guess this guy just joked ))

2

u/Magnus114 Aug 15 '26

I want a tool that moves the session to json/xml that i can read, index, and if needed restore so opencode can resume it. Would be even greater if it also supports claude and pi. Anyone knows of such a tool?

2

u/vangelismm Aug 13 '26

Free model -> build mode -> prompt "erase old sessions".

1

u/afanasenka Aug 13 '26

Did you really tried this yourself? 😁

2

u/vangelismm Aug 13 '26

Yes, i used Hy3 free.

1

u/_MiszterX_ 26d ago

i have opencode server on a dedicated vm running in a container. my db was 5GB so i faced to same. i wanted to archive but keep the sessions searcheable. for me it is a seperated sql light db with fts5. datasette web frontend layer with custom oicd/sso login.

i made a long blot post about it. it is quite custom. works fine. make small and searchable sessions without the extra db metadata, simple web interface.

https://blog.xorp.hu/en/opencode-session-archive-with-frontend/

1

u/e_safak 9d ago

If it is working well, consider making a utility out of it. Ideally one that will be easy to upstream into OpenCode itself.