You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sidebar USD spend decreases after compaction or revert #25023
The "$X.XX spent" figure in the TUI sidebar drops after a context compaction event, and again after a revert + new prompt. Compute spend isn't reversible, once paid to the LLM provider, it can't be unspent, so the displayed figure should be monotonic.
The cost stored on each assistant message in the DB is correct. The TUI bug is in how the figure is summed: it reduces over the visible message cache (capped at 100). After compaction the new summary turn pushes older paid messages out of the window, so the total drops even though spend hasn't changed. Hard-revert (revert.cleanup deleting messages from the DB before a new prompt) reproduces the same drop.
Aditional Information
I have a working fix locally and can send a PR if this approach is welcome: add a monotonic cost column on the session record, server-bumped per LLM step (and rolled up the parentID chain so sub-agent spend lands on the parent), with a one-time backfill from existing message costs on first read. The TUI then reads session.cost instead of summing over the visible message cache.
Happy to discuss the shape before opening the PR.
Plugins
No response
OpenCode version
1.14.29
Steps to reproduce
Open a session in the TUI that has accumulated >$0 spend across more than 100 messages, OR a session that's about to auto-compact.
Note the sidebar "$X.XX spent" figure.
Trigger /compact (or let auto-compaction fire).
Watch the sidebar figure — it drops, sometimes near half.
For the revert variant:
In a session with >$0 spend, revert to an earlier message.
Send a new prompt (forces revert.cleanup, which hard-deletes the reverted assistant turns from the DB).
The sidebar figure drops by the cost of the deleted turns.
Activity
github-actions commentedon Jul 3, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.