[Bug]: OpenCode threads via OpenRouter never show context-window usage in the composer
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 23k
- Forks
- 5.9k
- Avg merge
- 11h 14m
- Merged PRs (30d)
- 357
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
- Connect an OpenCode provider instance in T3 Code with an OpenRouter API key.
- Start a new thread and select any OpenRouter-routed model (tested: z-ai/glm-5.3-flash, poolside/laguna-s-2.1:free).
- Send several real messages back and forth so real usage accumulates.
- Inspect the context-window meter next to the composer send button.
Expected behavior
The context-window meter should appear and update with used/max tokens, same as it does for Codex and Claude threads. Issue #7622 states OpenCode already sends turn usage to the context meter in general.
Actual behavior
The meter area next to the send button stays completely empty, with no ring and no percentage, even after multiple completed turns with real token usage.
Impact
Minor bug or occasional failure
Version or commit
0.0.34
Environment
Windows 11, T3 Code desktop app, OpenCode provider connected via OpenRouter (API key)
Logs or stack traces
None. No error is shown, the meter is simply absent.
Technical notes
- Per #7622, OpenCode's turn usage is generally forwarded to the context meter, so this may be specific to OpenRouter-routed models rather than OpenCode as a whole.
- #8382 documents the same class of bug for the Grok provider, root-caused to the adapter not emitting
thread.token-usage.updated. The OpenCode-via-OpenRouter path may have the same gap, possibly because some OpenRouter models (especially free ones) omit or delay theusagefield in their API response.
Workaround
None found in-app. Running opencode directly in a terminal shows a working "Context X% used" indicator outside of T3 Code.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in apps/server and trace the OpenCode-via-OpenRouter usage path, comparing it with the behavior described in #7622 and the adapter issue in #8382. Confirm how turn usage reaches the context meter and whether OpenRouter responses provide the expected usage data or update event. Done means the composer meter appears and updates with used/max tokens for OpenRouter-routed OpenCode threads.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100