Dramatic increase in token consumption #668

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

Originally created by @cvkmohan on GitHub (Jul 12, 2025).

Originally assigned to: @thdxr on GitHub.

I have been using opencode for the last 10 days or so. I can say - intensively. However, till yesterday, not once did I reach a stage where we get out of tokens/out of context window. Even with reasonably big operations - somehow opencode managed to run - most of the times - not even reaching 50% of token size. However, from yesterday - after upgrade to 0.2.3x or so - suddenly, the consumption increased very significantly. Every restart getting exhausted in minutes. In fact, with my claude MAX $200 subscription - never reached its limits. In less than an hour - dramatically I am told that my limit gets reset after 4 hours.
Has something changed? Or problem is at my end?
Raising an issue because - nothing much changed in the way I use - but - I see a dramatic increase in token consumption and context exhaustion.

Just wanted to alert. Close it, if it is not related.

Originally created by @cvkmohan on GitHub (Jul 12, 2025). Originally assigned to: @thdxr on GitHub. I have been using opencode for the last 10 days or so. I can say - intensively. However, till yesterday, not once did I reach a stage where we get out of tokens/out of context window. Even with reasonably big operations - somehow opencode managed to run - most of the times - not even reaching 50% of token size. However, from yesterday - after upgrade to 0.2.3x or so - suddenly, the consumption increased very significantly. Every restart getting exhausted in minutes. In fact, with my claude MAX $200 subscription - never reached its limits. In less than an hour - dramatically I am told that my limit gets reset after 4 hours. Has something changed? Or problem is at my end? Raising an issue because - nothing much changed in the way I use - but - I see a dramatic increase in token consumption and context exhaustion. Just wanted to alert. Close it, if it is not related.
Author
Owner

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

can you reproduce a situation where the context window gets big faster than you expect a /share a link?

@thdxr commented on GitHub (Jul 12, 2025): can you reproduce a situation where the context window gets big faster than you expect a /share a link?
Author
Owner

@cvkmohan commented on GitHub (Jul 12, 2025):

Thanks for the quick response. I will share if it happens. So, no change on that front in code? One difference I can think of is the FigmaMCP that I used. Maybe its output is doing some mischief. Earlier with my Elixir Code - it never crossed 20% - including contexts, tests etc.

@cvkmohan commented on GitHub (Jul 12, 2025): Thanks for the quick response. I will share if it happens. So, no change on that front in code? One difference I can think of is the FigmaMCP that I used. Maybe its output is doing some mischief. Earlier with my Elixir Code - it never crossed 20% - including contexts, tests etc.
Author
Owner

@cvkmohan commented on GitHub (Jul 12, 2025):

https://opencode.ai/s/e7oOMJ1y

@cvkmohan commented on GitHub (Jul 12, 2025): https://opencode.ai/s/e7oOMJ1y
Author
Owner

@cvkmohan commented on GitHub (Jul 16, 2025):

I can confirm that token usage/context window usage has dramatically increased. I tried to run the same task in both claude cli and opencode cli - and opencode cli exhausted context window by the time claude cli reached 50%. Earlier it used to be reverse. Something changed.
Neither to hurry you nor cribbing. Just wanted to share the information. Please do not mind.

@cvkmohan commented on GitHub (Jul 16, 2025): I can confirm that token usage/context window usage has dramatically increased. I tried to run the same task in both claude cli and opencode cli - and opencode cli exhausted context window by the time claude cli reached 50%. Earlier it used to be reverse. Something changed. Neither to hurry you nor cribbing. Just wanted to share the information. Please do not mind.
Author
Owner

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

i looked through your session (if you open browser console in share page it prints out an object with everything)

i don't immediately notice anything suspicious - you can see in each step-finish part it report how many tokens it wrote into the cache

it progressively gets bigger - not sure

@thdxr commented on GitHub (Jul 16, 2025): i looked through your session (if you open browser console in share page it prints out an object with everything)<br><br>i don't immediately notice anything suspicious - you can see in each `step-finish` part it report how many tokens it wrote into the cache<br><br>it progressively gets bigger - not sure
Author
Owner

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

ahhh i think the issue is with every edit we include project level diagnostics and you have a lot of them. let me play with this

@thdxr commented on GitHub (Jul 16, 2025): ahhh i think the issue is with every edit we include project level diagnostics and you have a lot of them. let me play with this
Author
Owner

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

in 0.3.16 i filter out only Error diagnostics. we might remove them all together for project level ones but this is a first step

@thdxr commented on GitHub (Jul 16, 2025): in 0.3.16 i filter out only Error diagnostics. we might remove them all together for project level ones but this is a first step
Author
Owner

@ShivaR333 commented on GitHub (Jul 17, 2025):

Facing the same issue. Burnt through around 800K tokens for just a few edits. Is there any way to remove the diagnostics and start from a clean slate?

@ShivaR333 commented on GitHub (Jul 17, 2025): Facing the same issue. Burnt through around 800K tokens for just a few edits. Is there any way to remove the diagnostics and start from a clean slate?
Author
Owner

@adamdotdevin commented on GitHub (Jul 17, 2025):

@thdxr maybe we make this a flag to disable project diagnostics altogether, but default to errors only enabled

@adamdotdevin commented on GitHub (Jul 17, 2025): @thdxr maybe we make this a flag to disable project diagnostics altogether, but default to errors only enabled
Author
Owner

@cvkmohan commented on GitHub (Jul 17, 2025):

But, this is not a newly introduced feature. I was dealing with a bigger project (same in elixir, phoenix and liveview) a week before this issue - and - opencode was handling the context beautifully. I mean, it reached a maximum of 50% even with a long conversation. Something changed for sure.

@cvkmohan commented on GitHub (Jul 17, 2025): But, this is not a newly introduced feature. I was dealing with a bigger project (same in elixir, phoenix and liveview) a week before this issue - and - opencode was handling the context beautifully. I mean, it reached a maximum of 50% even with a long conversation. Something changed for sure.
Author
Owner

@claidler commented on GitHub (Jul 20, 2025):

@thdxr @adamdotdevin I'm noticing this also with GitHub Copilot as a provider in particular, across various projects seeing the token limit being hit after a few messages. I think it's probably related to diagnostic messages as I'm debugging some large error logs in both cases

@claidler commented on GitHub (Jul 20, 2025): @thdxr @adamdotdevin I'm noticing this also with GitHub Copilot as a provider in particular, across various projects seeing the token limit being hit after a few messages. I think it's probably related to diagnostic messages as I'm debugging some large error logs in both cases
Author
Owner

@jakubdonovan commented on GitHub (Jul 20, 2025):

in 0.3.16 i filter out only Error diagnostics. we might remove them all together for project level ones but this is a first step

I wanted to add that I’m also seeing extremely high input token usage on a relatively small SvelteKit project, even after adding an AGENTS.md file that excludes node_modules, .svelte-kit/, and build/ folders.

Since last night, I’ve already burned through $20 in usage, which is far beyond what I expected for this project.

Here’s the exact error I’m now encountering on each prompt:

[!ERROR]
{
  "data": {
    "message": "AI_APICallError: input length and max_tokens exceed context limit: 172775 + 32000 > 200000, decrease input length or max_tokens and try again"
  },
  "name": "UnknownError"
}

I also pulled my Claude usage logs and saw input token counts regularly in the 160k–172k range, all within minutes:

2025-07-20 14:29:30 — 172,448 tokens
2025-07-20 14:29:25 — 172,242 tokens
2025-07-20 14:29:15 — 171,931 tokens
...

I’ve tried compacting the session and deleting recent messages, but I’m now completely blocked due to the context limit being exceeded on every request. As a result, I am unable to do anything.

I’d be happy to share my session log privately if that helps with debugging

@jakubdonovan commented on GitHub (Jul 20, 2025): > in 0.3.16 i filter out only Error diagnostics. we might remove them all together for project level ones but this is a first step I wanted to add that I’m also seeing extremely high input token usage on a relatively small SvelteKit project, even after adding an AGENTS.md file that excludes node_modules, .svelte-kit/, and build/ folders. Since last night, I’ve already burned through $20 in usage, which is far beyond what I expected for this project. Here’s the exact error I’m now encountering on each prompt: ```json [!ERROR] {   "data": {     "message": "AI_APICallError: input length and max_tokens exceed context limit: 172775 + 32000 > 200000, decrease input length or max_tokens and try again"   },   "name": "UnknownError" } ``` I also pulled my Claude usage logs and saw input token counts regularly in the 160k–172k range, all within minutes: > 2025-07-20 14:29:30 — 172,448 tokens > 2025-07-20 14:29:25 — 172,242 tokens > 2025-07-20 14:29:15 — 171,931 tokens > ... I’ve tried compacting the session and deleting recent messages, but I’m now completely blocked due to the context limit being exceeded on every request. As a result, I am unable to do anything. I’d be happy to share my session log privately if that helps with debugging
Author
Owner

@claidler commented on GitHub (Jul 20, 2025):

Yeah it's worth me stating that one of mine was particularly small also which is why I imagined it may be diagnostics related. I'm wondering if there are restrictions around reading very large files or very large logs. Mine had 3-4 normal files, but some large files after a build that may have been picked up, or some long logs.

@claidler commented on GitHub (Jul 20, 2025): Yeah it's worth me stating that one of mine was particularly small also which is why I imagined it may be diagnostics related. I'm wondering if there are restrictions around reading very large files or very large logs. Mine had 3-4 normal files, but some large files after a build that may have been picked up, or some long logs.
Author
Owner

@claidler commented on GitHub (Jul 21, 2025):

Reviewing with AI, it said that there are not per file context limitations - I wonder if there should be. If someone has a large pdf or text file that they need to commit in their project that keeps getting picked up, this would be a point of frustration. I understand not everyone would want this, so it might need to be configurable, but I think we could decide on a sensible default considering any good code project shouldn't have code files longer than a certain amount of lines.
Is there anything in place here, and if not, could we put something in place?

@claidler commented on GitHub (Jul 21, 2025): Reviewing with AI, it said that there are not per file context limitations - I wonder if there should be. If someone has a large pdf or text file that they need to commit in their project that keeps getting picked up, this would be a point of frustration. I understand not everyone would want this, so it might need to be configurable, but I think we could decide on a sensible default considering any good code project shouldn't have code files longer than a certain amount of lines. Is there anything in place here, and if not, could we put something in place?
Author
Owner

@ivanglushko commented on GitHub (Aug 5, 2025):

This is the issue for me as well, just a simple prompt skyrockets the token usage. Would be nice to see what files / additional info was sent.

@ivanglushko commented on GitHub (Aug 5, 2025): This is the issue for me as well, just a simple prompt skyrockets the token usage. Would be nice to see what files / additional info was sent.
Author
Owner

@raxtor commented on GitHub (Aug 19, 2025):

Yes, there is something wrong... plain message costs 45k+ tokens... e.g. Kimi K2 is not able work... and is possible somewhere set model provider for OpenRouter?
Image

@raxtor commented on GitHub (Aug 19, 2025): Yes, there is something wrong... plain message costs 45k+ tokens... e.g. Kimi K2 is not able work... and is possible somewhere set model provider for OpenRouter? <img width="1920" height="1080" alt="Image" src="https://github.com/user-attachments/assets/6caf56d5-8603-4732-86c7-bf95f38e5a3f" />
Author
Owner

@rekram1-node commented on GitHub (Aug 19, 2025):

@raxtor seems like the kimi k2 free configuration is off we will investigate

@rekram1-node commented on GitHub (Aug 19, 2025): @raxtor seems like the kimi k2 free configuration is off we will investigate
Author
Owner

@timcreatedit commented on GitHub (Sep 10, 2025):

I also fully can't use opencode with claude anymore, it often maxes out after my first message.

@timcreatedit commented on GitHub (Sep 10, 2025): I also fully can't use opencode with claude anymore, it often maxes out after my first message.
Author
Owner

@mrgoonie commented on GitHub (Sep 16, 2025):

@thdxr I think in v0.9.5 the token count is incorrect:

Screenshot: (26.4K for a simple prompt)

Image

But when I open the shared session, it's showing 252 tokens: https://opencode.ai/s/Whzi8BH0

Image
@mrgoonie commented on GitHub (Sep 16, 2025): @thdxr I think in `v0.9.5` the token count is incorrect: Screenshot: (26.4K for a simple prompt) <img width="898" height="1033" alt="Image" src="https://github.com/user-attachments/assets/f2db7f1a-c82d-48ea-bb8e-604f8fda55e8" /> But when I open the shared session, it's showing `252 tokens`: https://opencode.ai/s/Whzi8BH0 <img width="890" height="1030" alt="Image" src="https://github.com/user-attachments/assets/59b5956d-a51b-4a95-a01e-6929244c385f" />
Author
Owner

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

do you have any MCP servers enabled? baseline should be around 11k

@thdxr commented on GitHub (Sep 17, 2025): do you have any MCP servers enabled? baseline should be around 11k
Author
Owner

@mrgoonie commented on GitHub (Sep 17, 2025):

yes, I have a couple ones, is there a way to see how many tokens that the MCP servers are taking?

@mrgoonie commented on GitHub (Sep 17, 2025): yes, I have a couple ones, is there a way to see how many tokens that the MCP servers are taking?
Author
Owner

@westito commented on GitHub (Oct 10, 2025):

MCP-s cost a lot of tokens! I enabled just a few. Figma, jetbrains, and it eats up 52k (20%) tokens!!

Figma use A LOT. I always keep it disabled and enable if I need. This is Claude Code, not OpenCode, but you can see context content there.

Image
MCP tools · /mcp
     └ mcp__ide__getDiagnostics (ide): 560 tokens
     └ mcp__context7__resolve-library-id (context7): 874 tokens
     └ mcp__context7__get-library-docs (context7): 835 tokens
     └ mcp__dart__connect_dart_tooling_daemon (dart): 634 tokens
     └ mcp__dart__get_runtime_errors (dart): 631 tokens
     └ mcp__dart__hot_reload (dart): 633 tokens
     └ mcp__dart__get_widget_tree (dart): 569 tokens
     └ mcp__dart__get_selected_widget (dart): 569 tokens
     └ mcp__dart__set_widget_selection_mode (dart): 601 tokens
     └ mcp__dart__get_active_location (dart): 577 tokens
     └ mcp__dart__pub_dev_search (dart): 1.0k tokens
     └ mcp__dart__dart_fix (dart): 675 tokens
     └ mcp__dart__dart_format (dart): 719 tokens
     └ mcp__dart__run_tests (dart): 2.1k tokens
     └ mcp__dart__create_project (dart): 844 tokens
     └ mcp__dart__pub (dart): 773 tokens
     └ mcp__dart__analyze_files (dart): 546 tokens
     └ mcp__dart__resolve_workspace_symbol (dart): 671 tokens
     └ mcp__dart__signature_help (dart): 639 tokens
     └ mcp__dart__hover (dart): 648 tokens
     └ mcp__figma__get_screenshot (figma): 1.1k tokens
     └ mcp__figma__create_design_system_rules (figma): 851 tokens
     └ mcp__figma__get_code (figma): 1.1k tokens
     └ mcp__figma__get_metadata (figma): 1.1k tokens
     └ mcp__jetbrains__execute_run_configuration (jetbrains): 814 tokens
     └ mcp__jetbrains__get_run_configurations (jetbrains): 705 tokens
     └ mcp__jetbrains__get_file_problems (jetbrains): 785 tokens
     └ mcp__jetbrains__get_project_dependencies (jetbrains): 647 tokens
     └ mcp__jetbrains__get_project_modules (jetbrains): 652 tokens
     └ mcp__jetbrains__create_new_file (jetbrains): 765 tokens
     └ mcp__jetbrains__find_files_by_glob (jetbrains): 859 tokens
     └ mcp__jetbrains__find_files_by_name_keyword (jetbrains): 813 tokens
     └ mcp__jetbrains__get_all_open_file_paths (jetbrains): 659 tokens
     └ mcp__jetbrains__list_directory_tree (jetbrains): 755 tokens
     └ mcp__jetbrains__open_file_in_editor (jetbrains): 696 tokens
     └ mcp__jetbrains__reformat_file (jetbrains): 680 tokens
     └ mcp__jetbrains__get_file_text_by_path (jetbrains): 838 tokens
     └ mcp__jetbrains__replace_text_in_file (jetbrains): 1.0k tokens
     └ mcp__jetbrains__search_in_files_by_regex (jetbrains): 873 tokens
     └ mcp__jetbrains__search_in_files_by_text (jetbrains): 871 tokens
     └ mcp__jetbrains__get_symbol_info (jetbrains): 830 tokens
     └ mcp__jetbrains__rename_refactoring (jetbrains): 959 tokens
     └ mcp__jetbrains__execute_terminal_command (jetbrains): 1.0k tokens
     └ mcp__jetbrains__get_repositories (jetbrains): 651 tokens
@westito commented on GitHub (Oct 10, 2025): MCP-s cost a lot of tokens! I enabled just a few. Figma, jetbrains, and it eats up 52k (20%) tokens!! Figma use A LOT. I always keep it disabled and enable if I need. This is Claude Code, not OpenCode, but you can see context content there. <img width="670" height="229" alt="Image" src="https://github.com/user-attachments/assets/dfd71d6e-90fc-4e47-bb69-f9bf70861b0c" /> ``` MCP tools · /mcp └ mcp__ide__getDiagnostics (ide): 560 tokens └ mcp__context7__resolve-library-id (context7): 874 tokens └ mcp__context7__get-library-docs (context7): 835 tokens └ mcp__dart__connect_dart_tooling_daemon (dart): 634 tokens └ mcp__dart__get_runtime_errors (dart): 631 tokens └ mcp__dart__hot_reload (dart): 633 tokens └ mcp__dart__get_widget_tree (dart): 569 tokens └ mcp__dart__get_selected_widget (dart): 569 tokens └ mcp__dart__set_widget_selection_mode (dart): 601 tokens └ mcp__dart__get_active_location (dart): 577 tokens └ mcp__dart__pub_dev_search (dart): 1.0k tokens └ mcp__dart__dart_fix (dart): 675 tokens └ mcp__dart__dart_format (dart): 719 tokens └ mcp__dart__run_tests (dart): 2.1k tokens └ mcp__dart__create_project (dart): 844 tokens └ mcp__dart__pub (dart): 773 tokens └ mcp__dart__analyze_files (dart): 546 tokens └ mcp__dart__resolve_workspace_symbol (dart): 671 tokens └ mcp__dart__signature_help (dart): 639 tokens └ mcp__dart__hover (dart): 648 tokens └ mcp__figma__get_screenshot (figma): 1.1k tokens └ mcp__figma__create_design_system_rules (figma): 851 tokens └ mcp__figma__get_code (figma): 1.1k tokens └ mcp__figma__get_metadata (figma): 1.1k tokens └ mcp__jetbrains__execute_run_configuration (jetbrains): 814 tokens └ mcp__jetbrains__get_run_configurations (jetbrains): 705 tokens └ mcp__jetbrains__get_file_problems (jetbrains): 785 tokens └ mcp__jetbrains__get_project_dependencies (jetbrains): 647 tokens └ mcp__jetbrains__get_project_modules (jetbrains): 652 tokens └ mcp__jetbrains__create_new_file (jetbrains): 765 tokens └ mcp__jetbrains__find_files_by_glob (jetbrains): 859 tokens └ mcp__jetbrains__find_files_by_name_keyword (jetbrains): 813 tokens └ mcp__jetbrains__get_all_open_file_paths (jetbrains): 659 tokens └ mcp__jetbrains__list_directory_tree (jetbrains): 755 tokens └ mcp__jetbrains__open_file_in_editor (jetbrains): 696 tokens └ mcp__jetbrains__reformat_file (jetbrains): 680 tokens └ mcp__jetbrains__get_file_text_by_path (jetbrains): 838 tokens └ mcp__jetbrains__replace_text_in_file (jetbrains): 1.0k tokens └ mcp__jetbrains__search_in_files_by_regex (jetbrains): 873 tokens └ mcp__jetbrains__search_in_files_by_text (jetbrains): 871 tokens └ mcp__jetbrains__get_symbol_info (jetbrains): 830 tokens └ mcp__jetbrains__rename_refactoring (jetbrains): 959 tokens └ mcp__jetbrains__execute_terminal_command (jetbrains): 1.0k tokens └ mcp__jetbrains__get_repositories (jetbrains): 651 tokens ```
Author
Owner

@rekram1-node commented on GitHub (Oct 10, 2025):

having context breakdown is good we should have that too

@rekram1-node commented on GitHub (Oct 10, 2025): having context breakdown is good we should have that too
Author
Owner

@Nindaleth commented on GitHub (Dec 18, 2025):

@rekram1-node Is there an issue tracking the context breakdown that I could subscribe to? I can't seem to find it.

@Nindaleth commented on GitHub (Dec 18, 2025): @rekram1-node Is there an issue tracking the context breakdown that I could subscribe to? I can't seem to find it.
Author
Owner

@rekram1-node commented on GitHub (Dec 18, 2025):

Idk if we do tbh can't find one

@rekram1-node commented on GitHub (Dec 18, 2025): Idk if we do tbh can't find one
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#668