Skip to content

Massive token usage + counts don't add up? #23551

@agardnerIT

Description

@agardnerIT

Question

Hi all. I'm seeing some behaviour that I'm struggling to explain. When I run the example command from here: opencode run "Explain how closures work in JavaScript"

The UI seems to suggest that took over 20,000 input tokens!? But then I click the UI and it shows 10k - so they don't add up?

Where are all of those tokens coming from and how do I lower it?

Image

Logs

~/.local/share/opencode/logs/....log

INFO  2026-04-20T12:52:15 +351ms service=server-proxy version=1.14.19 args=["run","Explain how closures work in JavaScript"] process_role=main run_id=002e5d19-3523-4a12-b9af-75a2b912ae86 opencode
ERROR 2026-04-20T12:52:20 +5218ms service=llm providerID=opencode-go modelID=qwen3.5-plus session.id=ses_2550d25e1ffeOMMcu8o5Ce2Ufv small=false agent=build mode=primary error={"error":{"name":"AI_APICallError","url":"https://opencode.ai/zen/go/v1/chat/completions","requestBodyValues":{"model":"qwen3.5-plus","max_tokens":32000,"temperature":0.55,"top_p":1,"messages":[{"role":"system","content":[{"type":"text","text":"You are opencode, an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.\n\nIMPORTANT: You must NEVER generate or guess URLs for the user unless you are confident that the URLs are for helping the user with programming. You may use URLs provided by the user in their messages or local files.\n\nIf the user asks for help or wants to give feedback inform them of the following:\n- /help: Get help with using opencode\n- To give feedback, users should report the issue at https://github.com/anomalyco/opencode/issues\n\nWhen the user directly asks about opencode (eg 'can opencode do...', 'does opencode have...') or asks in second person (eg 'are you able...', 'can you do...'), first use the WebFetch tool to gather 

REDACTING THIS ENORMOUS SYSTEM PROMPT

arameters":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"name":{"description":"The name of the skill from available_skills","type":"string"}},"required":["name"],"additionalProperties":false}}}],"tool_choice":"auto","stream":true,"stream_options":{"include_usage":true}},"statusCode":429,"responseHeaders":{"cf-ray":"9ef4492bfb316192-PDX","connection":"keep-alive","content-length":"333","content-type":"application/json","date":"Mon, 20 Apr 2026 12:52:27 GMT","server":"cloudflare"},"responseBody":"{\"error\":{\"message\":\"Error from provider (Alibaba): You exceeded your current quota, please check your plan and billing details. For details, see: https://help.aliyun.com/zh/model-studio/error-code#token-limit\",\"type\":\"insufficient_quota\",\"param\":null,\"code\":\"insufficient_quota\"},\"request_id\":\"1296b699-f7bb-499c-9cb1-1e63ba3e4131\"}","isRetryable":true,"data":{"error":{"message":"Error from provider (Alibaba): You exceeded your current quota, please check your plan and billing details. For details, see: https://help.aliyun.com/zh/model-studio/error-code#token-limit","code":"insufficient_quota","type":"insufficient_quota"}}}} stream error
  1. I don't know why I get a 429 as I'm on Go and have plenty of quota left.
  2. To make matters worse, the CLI retries so it sends that prompt twice.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions