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
[BUG] Negative amount of tokens used in session #15293
There is an issue in sessions index.ts where there is a possibility to get negative amount of tokens, as code assumes that input tokens have cached in it. And if cached amount is more than input amount - we got negative. Nothing prevents it.
This can cause issues on analytics tools which are using sessions data assuming tokens always positive.
Plugins
superpowers, DCP
OpenCode version
1.2.15
Steps to reproduce
I faced it with minimax-m2.5 on nanoGPT I believe, if you want to reproduce. At least according to my agent ;) As I used 4 different models within that session, and not completely sure.
Adding one more confirming data point from a separate investigation.
While analyzing long delayed turns in a session tree, we also observed negative input-token values on some turns, including turns that otherwise appeared to have cache reads recorded. For example:
Class
Input tokens
Cache read
Result
Primary
-423
84,160
tool-calls
Secondary
-132
57,664
tool-calls
We did not rely on those negative values semantically, but they made the cache / token evidence harder to interpret. This seems consistent with the accounting bug described here rather than with a literal negative prompt size.
Related issue with the fuller anonymized slowdown/cache analysis: #20565
Activity
github-actions commentedon Feb 26, 2026
This issue might be a duplicate of existing issues. Please check:
rothnic commentedon Apr 2, 2026
Adding one more confirming data point from a separate investigation.
While analyzing long delayed turns in a session tree, we also observed negative input-token values on some turns, including turns that otherwise appeared to have cache reads recorded. For example:
We did not rely on those negative values semantically, but they made the cache / token evidence harder to interpret. This seems consistent with the accounting bug described here rather than with a literal negative prompt size.
Related issue with the fuller anonymized slowdown/cache analysis: #20565
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.