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
Currently, opencode tracks token usage in a single thread, including pricing when using API models. However, there is no tool to track overall usage or spend with the tool. Is it possible to add a slash command (e.g. /usage or /stats) that would track the overall spend and/or token usage across sessions in a specific time interval? This would be helpful for claude code users especially since otherwise there is no way to know how much usage you are getting out of your account.
Given I have a primary agent active.
When the primary agent has `token_reports: true`
Then token usage data is logged at the default reporting tick resolution (15 seconds).
And
Given I am in an active session.
And given the primary agent has `token_reports: true` (boolean)
And given the primary agent has `token_reports_tick: 5` (seconds)
When I use the top level built in `/tokens` or `/usage` or `/consumption`
Then I see the table of token usage:
| Time | Session | Command | Agent | Model | TSent | TReceived | TTotal | SentCostGuesstimate | ReceivedCostGuesstimate | TotalCostGuestimate |
@aleks-mariusz is the above what you had in mind? In your case you would set token_reports_tick: 1 in your primary agent file.
Hey @rekram1-node! I've been working on implementing this and have a draft PR ready #3832.
What I did: Went with the simpler approach traverse all sessions/messages to aggregate stats. No storage schema changes needed, just working with what's already there.
Current state: Works kinda alright on my setup (M4 Pro, 24GB RAM: 14 sessions, ~1.5k messages = ~1.3s), but I'm not sure how it scales for users with 100+ or 1000+ sessions.
Wanted to get feedback:
Is this acceptable for v1?
What's typical session volume per user?
If anyone's willing to test with their setup, that would help me understand real world performance.
This is my first contribution, so happy to iterate based on what you think makes sense. Let me know!
Activity
x4132 commentedon Aug 10, 2025
@thdxr BTW i would be open to implement/make a PR for this if you'd like
marcinpz commentedon Sep 19, 2025
what about having performance stats in logs?
djmaze commentedon Oct 1, 2025
There seems to be a WIP stats command half-implemented in the repo already: https://github.com/sst/opencode/blob/dev/packages/opencode/src/cli/cmd/stats.ts
aleks-mariusz commentedon Oct 5, 2025
along the same lines, how about we have a tokens-per-second output as well please?
taqtiqa-mark commentedon Oct 13, 2025
And
@aleks-mariusz is the above what you had in mind? In your case you would set
token_reports_tick: 1in your primary agent file.kaanmertkoc commentedon Nov 2, 2025
hey! i would also like to make this feature happen!
@x4132 are you currently developing a PR? Or is there any other related PR's that are trying to implement this feature? I am new to this repo!
rekram1-node commentedon Nov 2, 2025
@kaanmertkoc I think if you want to finish the implementation here that'd be awesome
kaanmertkoc commentedon Nov 2, 2025
yes, thanks! i will try to finish it 🫡🫡🫡 thank you for your quick response.
rekram1-node commentedon Nov 2, 2025
no problem!
x4132 commentedon Nov 2, 2025
kaanmertkoc commentedon Nov 3, 2025
Hey @rekram1-node! I've been working on implementing this and have a draft PR ready #3832.
What I did: Went with the simpler approach traverse all sessions/messages to aggregate stats. No storage schema changes needed, just working with what's already there.
Current state: Works kinda alright on my setup (M4 Pro, 24GB RAM: 14 sessions, ~1.5k messages = ~1.3s), but I'm not sure how it scales for users with 100+ or 1000+ sessions.
Wanted to get feedback:
This is my first contribution, so happy to iterate based on what you think makes sense. Let me know!
rekram1-node commentedon Nov 3, 2025
@kaanmertkoc just at a glance it looks good, I have a decent # of sessions so ill test it but it seems like it will be good to merge
kaanmertkoc commentedon Nov 3, 2025
That's very good to hear! Just let me know about the results :)
fix den mcp tool input schemas (anomalyco#1634)