[bug] Token usage info WAY off, failed request
Hey @thdxr ,
just tried to use opencode to generate me some overviews and dunno what exactly happened, but the token usage is WAY off and the request failed. Even the TUI flickered for som reason while "working..." showed at the bottom - there also were 2 prompts at the same time (there were two subfolders, so it created 2 agents??) - might be a feature (not sure).
Obviously, also the price was higher - no $0.01, but $0.18.
Here is the share link: https://dev.opencode.ai/s/522f35d1
Also, attaching a screenshot of the TUI:
And even the Anthropic Usage info, so you see the difference in token usage and at the bottom - blocked API calls...
Here are the logs - it sent a quite a lot of requests too (blurred the request ids just in case):
EDIT: yup, it spawned 2 child sessions and everything was going off at the same time - both produced $0.06 (which still doesnt add up to $0.18 of costs, but we're getting there) and around 20k of tokens each - everything together created a lot of load on the API - this thing should/could be handled somehow on the opencode's side IMHO - to detect the size before sending it off (maybe an Anthropic API mode VS the Claude Pro/Max mode where it compresses more agressively)
Going to bed, gonna come back in around 10 hours time (if any input is needed)
if possible can you open up the session again and do /share and see if the cost listed on that page is the same?
if possible can you open up the session again and do
/shareand see if the cost listed on that page is the same?
Didn't change much on the last message, but it worked and produced an output :) See the share link
The compacting command from #180 could help :)
Even the TUI flickered for som reason while "working..." showed at the bottom
Not sure if related, but I noticed this same "flickering" in the TUI. It happened for about 20 seconds (or so) rapidly while this "TASK ..." message was shown. As if stuff was happening in the background. Eventually it stopped and then displayed the last message shown in my screenshot.
I use a proxy so was monitoring the requests it was sending during this time and while it sent multiple (a few) it definitely was NOT spamming a bunch of API calls... this leads me to believe it was maybe doing tool calls locally or mcp stuff or something in the background?
Just tried using OpenRouter and this is the result:
Percentages and cost don't seem right at all. Here are the real ones (also why was the last prompt 33k tokens :D):
Share doesn't really work either, throws a 500... But here's the link anyway: https://dev.opencode.ai/s/7c052e39
EDIT: a rather simple prompt to make a change in an ETL script cost me 2 dollars and used 500k tokens
the % is off because when you configure a custom provider + model you have to specify what the max content length is
i'm looking into getting openrouter to use input token caching though
i got it working and it's released in 0.1.94 - i can see in the openrouter dashboard caching is drastically decreasing cost
going to close this issue for now because it's mixing a few different problems - feel free to reopen more specific ones