Ridiculously big usage of input tokens for simple tasks #183

Open
opened 2026-02-16 17:25:37 -05:00 by yindo · 11 comments
Owner

Originally created by @kazzkiq on GitHub (Jun 20, 2025).

Originally assigned to: @thdxr on GitHub.

  • Input: Create me a sample.js file with a fibonacci function inside it.
  • Model: gemini-2.5-flash
  • Tokens spent: 10.2k ⚠

Result after a few simple inputs:

Image

Curious as to why so many tokens are spent for such a simple task.

Originally created by @kazzkiq on GitHub (Jun 20, 2025). Originally assigned to: @thdxr on GitHub. - Input: `Create me a sample.js file with a fibonacci function inside it.` - Model: `gemini-2.5-flash` - Tokens spent: 10.2k ⚠ Result after a few simple inputs: <img width="1004" alt="Image" src="https://github.com/user-attachments/assets/d1d3a2f2-e658-45e3-abc9-d3f78b1e563c" /> Curious as to why so many tokens are spent for such a simple task.
yindo added the bad label 2026-02-16 17:25:37 -05:00
Author
Owner

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

what version was this on?

@thdxr commented on GitHub (Jun 20, 2025): what version was this on?
Author
Owner

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

looking at this again - our tool descriptions + system prompt are extracted from claude code

they are quite long and total to about 10K tokens - but anthropic has input token caching which makes this less of an issue

i think i just need to make sure that works on google (if possible) and also we plan on having different tools + descriptions per provider

@thdxr commented on GitHub (Jun 20, 2025): looking at this again - our tool descriptions + system prompt are extracted from claude code they are quite long and total to about 10K tokens - but anthropic has input token caching which makes this less of an issue i think i just need to make sure that works on google (if possible) and also we plan on having different tools + descriptions per provider
Author
Owner

@bigcodegen commented on GitHub (Jun 20, 2025):

Cline had a similar issue early on until they implemented caching everywhere and scaled back the prompts a bit

@bigcodegen commented on GitHub (Jun 20, 2025): Cline had a similar issue early on until they implemented caching everywhere and scaled back the prompts a bit
Author
Owner

@mosheduminer commented on GitHub (Jul 2, 2025):

As another data point, someone told me he tried using opencode with a free Gemini API key (and apparently did not continue trying to test it out), and got rate limited immediately. So this ticket is probably worth fixing so people can try out opencode easily (especially if they're looking to compare with what they get from Gemini CLI.

@mosheduminer commented on GitHub (Jul 2, 2025): As another data point, someone told me he tried using opencode with a free Gemini API key (and apparently did not continue trying to test it out), and got rate limited immediately. So this ticket is probably worth fixing so people can try out opencode easily (especially if they're looking to compare with what they get from Gemini CLI.
Author
Owner

@thdxr commented on GitHub (Jul 2, 2025):

the thing is for the level of quality we want to provide we do need this level of tool call descriptions. so first message will always be 10K

but we haven't implemented caching on gemini and caching is crucial to make this all work

@thdxr commented on GitHub (Jul 2, 2025): the thing is for the level of quality we want to provide we do need this level of tool call descriptions. so first message will always be 10K<br><br>but we haven't implemented caching on gemini and caching is crucial to make this all work
Author
Owner

@mictadlo commented on GitHub (Nov 8, 2025):

This plugin authenticate the Opencode CLI with your Google account so you can use your existing Gemini plan and its included quota instead of API billing.

I set the plugin inside OpenCode in the following way up:

kozabaa@05968-nb:~$ cat ~/.config/opencode/opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["opencode-gemini-auth"]
}
kozabaa@05968-nb:~$ opencode auth login

┌  Add credential
│
◇  Select provider
│  Google
│
◆  Login method
│  ● OAuth with Google (Gemini CLI)
│  ○ Manually enter API Key

Next I tested whether prompt caching is used in Gemini:

opencode run "@dir . Count the number of functions in this codebase" --model google/gemini-2.5-pro --format json

In the first run I got:

"tokens":{"input":10850,"output":10,"reasoning":32,"cache":{"read":0,"write":0}

And second run gave me:

"tokens":{"input":10856,"output":10,"reasoning":74,"cache":{"read":9051,"write":0}}}}

After the Gemini test I tested Clause in similar way:

 opencode run "@dir . Count the number of functions in this codebase" --model anthropic/claude-sonnet-4-5 --format json

In the first run I got:

"tokens":{"input":6,"output":88,"reasoning":0,"cache":{"read":11475,"write":335}}}}

and in the second run I got:

"tokens":{"input":6,"output":80,"reasoning":0,"cache":{"read":11316,"write":342}}}}

Now I am confused.

  1. Why was the cache not empty when running Claude?
  2. Does OpenCode uses its own prompt caching?
@mictadlo commented on GitHub (Nov 8, 2025): This [plugin](https://github.com/jenslys/opencode-gemini-auth) authenticate the Opencode CLI with your Google account so you can use your existing Gemini plan and its included quota instead of API billing. I set the plugin inside OpenCode in the following way up: ``` kozabaa@05968-nb:~$ cat ~/.config/opencode/opencode.json { "$schema": "https://opencode.ai/config.json", "plugin": ["opencode-gemini-auth"] } ``` ``` kozabaa@05968-nb:~$ opencode auth login ┌ Add credential │ ◇ Select provider │ Google │ ◆ Login method │ ● OAuth with Google (Gemini CLI) │ ○ Manually enter API Key ``` Next I tested whether prompt caching is used in Gemini: ``` opencode run "@dir . Count the number of functions in this codebase" --model google/gemini-2.5-pro --format json ``` In the first run I got: ``` "tokens":{"input":10850,"output":10,"reasoning":32,"cache":{"read":0,"write":0} ``` And second run gave me: ``` "tokens":{"input":10856,"output":10,"reasoning":74,"cache":{"read":9051,"write":0}}}} ``` After the Gemini test I tested Clause in similar way: ```` opencode run "@dir . Count the number of functions in this codebase" --model anthropic/claude-sonnet-4-5 --format json ```` In the first run I got: ``` "tokens":{"input":6,"output":88,"reasoning":0,"cache":{"read":11475,"write":335}}}} ``` and in the second run I got: ``` "tokens":{"input":6,"output":80,"reasoning":0,"cache":{"read":11316,"write":342}}}} ``` Now I am confused. 1. Why was the cache not empty when running Claude? 2. Does OpenCode uses its own prompt caching?
Author
Owner

@rekram1-node commented on GitHub (Nov 8, 2025):

@mictadlo the cache read is coming directly from the provider we are just reporting it back to u

@rekram1-node commented on GitHub (Nov 8, 2025): @mictadlo the cache read is coming directly from the provider we are just reporting it back to u
Author
Owner

@Congee commented on GitHub (Nov 20, 2025):

i'm on claude pro subscription and got rate limited in an hour and that was just editing one file of regular size :/ How can I help? Don't really want to switch from opencode
Image

@Congee commented on GitHub (Nov 20, 2025): i'm on claude pro subscription and got rate limited in an hour and that was just editing one file of regular size :/ How can I help? Don't really want to switch from opencode <img width="1270" height="781" alt="Image" src="https://github.com/user-attachments/assets/06b75983-a267-49e9-ae43-d9fede458a65" />
Author
Owner

@rekram1-node commented on GitHub (Nov 20, 2025):

whats the ratelimit

@rekram1-node commented on GitHub (Nov 20, 2025): whats the ratelimit
Author
Owner

@Congee commented on GitHub (Nov 20, 2025):

whats the ratelimit

I'm on Tier 1, with sonnet 4.5

Model Requests Per Minute Input Tokens Per Minute Output Tokens Per Minute
Claude Haiku 4.x 50 50K \le 200K context, excluding cache reads 10K \le 200K context
Claude Sonnet 4.x 50 30K \le 200K context, excluding cache reads 8K \le 200K context
Claude Opus 4.x 50 30K \le 200K context, excluding cache reads 8K \le 200K context
Claude Sonnet 3.7 50 20K \le 200K context, excluding cache reads 8K \le 200K context
Claude Haiku 3.5 50 50K \le 200K context 10K \le 200K context
Claude Haiku 3 50 50K \le 200K context 10K \le 200K context

This is probably confusing, because the API seems to have a limit window of a few hours. Anyway, the point is unnecessary amount tokens input. Claude Code does not have this problem.

Claude Code may be using a proprietary endpoint?

@Congee commented on GitHub (Nov 20, 2025): > whats the ratelimit I'm on Tier 1, with sonnet 4.5 | Model | Requests Per Minute | Input Tokens Per Minute | Output Tokens Per Minute | | :--- | :--- | :--- | :--- | | Claude Haiku 4.x | 50 | 50K $\le$ 200K context, excluding cache reads | 10K $\le$ 200K context | | Claude Sonnet 4.x | 50 | 30K $\le$ 200K context, excluding cache reads | 8K $\le$ 200K context | | Claude Opus 4.x | 50 | 30K $\le$ 200K context, excluding cache reads | 8K $\le$ 200K context | | Claude Sonnet 3.7 | 50 | 20K $\le$ 200K context, excluding cache reads | 8K $\le$ 200K context | | Claude Haiku 3.5 | 50 | 50K $\le$ 200K context | 10K $\le$ 200K context | | Claude Haiku 3 | 50 | 50K $\le$ 200K context | 10K $\le$ 200K context | This is probably confusing, because the API seems to have a limit window of a few hours. Anyway, the point is unnecessary amount tokens input. Claude Code does not have this problem. Claude Code may be using a proprietary endpoint?
Author
Owner

@rekram1-node commented on GitHub (Nov 21, 2025):

Im not really sure, unless this is something that is happening to you repeatedly and only with opencode?

Are you using more MCPs with opencode? Our # of tools is similar to claude code and should be right around same number of tokens too

@rekram1-node commented on GitHub (Nov 21, 2025): Im not really sure, unless this is something that is happening to you repeatedly and only with opencode? Are you using more MCPs with opencode? Our # of tools is similar to claude code and should be right around same number of tokens too
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#183