You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OpenCode usage double-counts turns that OpenCode runs through Claude Code (claude-agent) #46303
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
In OpenCode, use a model from its claude-agent provider (it runs the Claude Code CLI on your Claude subscription), e.g. claude-agent/sonnet.
Allow both OpenCode and Claude Code in T3 Code's Usage access.
Open Usage and compare the OpenCode and Claude Code totals for the same period.
Expected behavior
Each turn is counted once. These turns run the real Claude Code CLI on the Claude subscription, so they belong under Claude Code.
Actual behavior
Each turn is counted twice: once by the OpenCode reader from opencode.db (rows with providerID: "claude-agent") and once by the Claude Code reader from Claude Code's own transcript in ~/.claude/projects, where the lines are tagged "entrypoint":"opencode".
On my machine, from Nov 29 to now there were 59 claude-agent assistant messages in opencode.db and 59 distinct Claude Code assistant messages tagged entrypoint: "opencode", a one-for-one match. Over all history there are ~53k claude-agent messages in opencode.db.
Impact
Token and cost totals for anyone routing Claude Code through OpenCode are inflated by the full size of that usage, and the same work appears under two providers.
Version or commit
v0.1.13 (stable)
Environment
macOS 27.2.1, desktop app. OpenCode with claude-agent, opencode-go, opencode and xai providers.
Logs or stack traces
Counts above came from read-only queries:
-- opencode.dbSELECTcount(*) FROM session_message
WHERE json_extract(data,'$.model.providerID')='claude-agent'AND time_created >=<since>;
and counting distinct message.id on "type":"assistant" lines containing "entrypoint":"opencode" in ~/.claude/projects/**/*.jsonl over the same window.
Workaround
None in the UI; mentally subtract the claude-agent rows from OpenCode.
🤖 Claude Opus 5.5 responding on behalf of @scoizzle
A fix is ready on my fork: scoizzle#2 (one commit on top of current main).
The OpenCode usage reader skips claude-agent messages, because Claude Code's own transcript already records those turns. The usage scan cache is bumped so OpenCode records that were cached earlier get re-read. The new reader test fails without the change. I can open it here as a PR if you'd like.
Activity
scoizzle commentedon Nov 30, 2026
Note
🤖 Claude Opus 5.5 responding on behalf of @scoizzle
A fix is ready on my fork: scoizzle#2 (one commit on top of current
main).The OpenCode usage reader skips
claude-agentmessages, because Claude Code's own transcript already records those turns. The usage scan cache is bumped so OpenCode records that were cached earlier get re-read. The new reader test fails without the change. I can open it here as a PR if you'd like.test(opencode): claude-agent usage is left to Claude Code's transcript (