Dramatic increase in token consumption
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.
can you reproduce a situation where the context window gets big faster than you expect a /share a link?
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.
https://opencode.ai/s/e7oOMJ1y
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.
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
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
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
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?
@thdxr maybe we make this a flag to disable project diagnostics altogether, but default to errors only enabled
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.
@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
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
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.
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?
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.
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?
@raxtor seems like the kimi k2 free configuration is off we will investigate
I also fully can't use opencode with claude anymore, it often maxes out after my first message.
@thdxr I think in v0.9.5 the token count is incorrect:
Screenshot: (26.4K for a simple prompt)
But when I open the shared session, it's showing 252 tokens: https://opencode.ai/s/Whzi8BH0
do you have any MCP servers enabled? baseline should be around 11k
yes, I have a couple ones, is there a way to see how many tokens that the MCP servers are taking?
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.
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
having context breakdown is good we should have that too
@rekram1-node Is there an issue tracking the context breakdown that I could subscribe to? I can't seem to find it.
Idk if we do tbh can't find one