[bug] Token usage info WAY off, failed request #111

Closed
opened 2026-02-16 17:25:14 -05:00 by yindo · 8 comments
Owner

Originally created by @luuk00101 on GitHub (Jun 17, 2025).

Originally assigned to: @adamdotdevin on GitHub.

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:

Image

And even the Anthropic Usage info, so you see the difference in token usage and at the bottom - blocked API calls...

Image

Here are the logs - it sent a quite a lot of requests too (blurred the request ids just in case):

Image

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)

Originally created by @luuk00101 on GitHub (Jun 17, 2025). Originally assigned to: @adamdotdevin on GitHub. 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: <img width="1440" alt="Image" src="https://github.com/user-attachments/assets/f577fade-b29a-462e-8187-b057a8193409" /> --- And even the Anthropic Usage info, so you see the difference in token usage and at the bottom - blocked API calls... <img width="867" alt="Image" src="https://github.com/user-attachments/assets/dc2fd896-6fe8-4ae1-bc36-72e6cf9dd76f" /> --- Here are the logs - it sent a quite a lot of requests too (blurred the request ids just in case): <img width="877" alt="Image" src="https://github.com/user-attachments/assets/38e27ae4-6959-47ee-bd89-e89a0b8114a2" /> --- **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)
yindo closed this issue 2026-02-16 17:25:14 -05:00
Author
Owner

@luuk00101 commented on GitHub (Jun 17, 2025):

Going to bed, gonna come back in around 10 hours time (if any input is needed)

@luuk00101 commented on GitHub (Jun 17, 2025): Going to bed, gonna come back in around 10 hours time (if any input is needed)
Author
Owner

@thdxr commented on GitHub (Jun 17, 2025):

if possible can you open up the session again and do /share and see if the cost listed on that page is the same?

@thdxr commented on GitHub (Jun 17, 2025): if possible can you open up the session again and do `/share` and see if the cost listed on that page is the same?
Author
Owner

@luuk00101 commented on GitHub (Jun 18, 2025):

if possible can you open up the session again and do /share and 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

@luuk00101 commented on GitHub (Jun 18, 2025): > if possible can you open up the session again and do `/share` and 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
Author
Owner

@luuk00101 commented on GitHub (Jun 18, 2025):

The compacting command from #180 could help :)

@luuk00101 commented on GitHub (Jun 18, 2025): The compacting command from #180 could help :)
Author
Owner

@GitMurf commented on GitHub (Jun 18, 2025):

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.

Image

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?

@GitMurf commented on GitHub (Jun 18, 2025): > 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. ![Image](https://github.com/user-attachments/assets/29e1a03c-e21e-444d-9c99-e2d21b1fb632) 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?
Author
Owner

@luuk00101 commented on GitHub (Jun 19, 2025):

Just tried using OpenRouter and this is the result:

Image

Percentages and cost don't seem right at all. Here are the real ones (also why was the last prompt 33k tokens :D):

Image

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

@luuk00101 commented on GitHub (Jun 19, 2025): Just tried using OpenRouter and this is the result: <img width="1440" alt="Image" src="https://github.com/user-attachments/assets/c15204f7-2b33-4969-817d-d9c4cfe16315" /> Percentages and cost don't seem right at all. Here are the real ones (also why was the last prompt 33k tokens :D): <img width="1152" alt="Image" src="https://github.com/user-attachments/assets/fbdbef6a-9528-47a6-8609-1a8cef5f8e4c" /> 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
Author
Owner

@thdxr commented on GitHub (Jun 19, 2025):

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

@thdxr commented on GitHub (Jun 19, 2025): 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
Author
Owner

@thdxr commented on GitHub (Jun 19, 2025):

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

@thdxr commented on GitHub (Jun 19, 2025): 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
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#111