Skip to content

OpenCode provider double-counts Claude Code usage when Claude Code runs through OpenCode (e.g. OpenChamber) #443

Open

Description

@ilker-sahin

Problem

When Claude Code is driven through an OpenCode-based wrapper such as OpenChamber, every request is counted twice: once by the Claude Code provider and once by the OpenCode provider.

The wrapper runs OpenCode's session engine with a claude-code provider that delegates the work to Claude Code. So each request ends up in two places:

  1. Claude Code's own logs under ~/.claude/projects/**/*.jsonl, read by the Claude Code provider.
  2. OpenCode's database (opencode.db), where the assistant message is stored with providerID = "claude-code", read by the OpenCode provider.

The OpenCode provider has no way to know that second copy is the same usage Claude Code already logged, so the daily total is inflated by roughly the full Claude Code volume.

Evidence

Measured on one day of mixed use (OpenChamber with the claude-code provider, plus a little native OpenCode):

Source Tokens
Poke Token Bar, Claude Code ~220M
Poke Token Bar, OpenCode ~216M
Claude Code logs, recomputed (deduped by message id + request id) ~220M
opencode.db assistant rows with providerID = "claude-code" ~218M
opencode.db assistant rows from native OpenCode providers ~3M

About 98% of the "OpenCode" total is the mirror of Claude Code usage that is already counted under Claude Code.

Expected

Claude Code usage is counted once. OpenCode only reports usage that Claude Code's own logs don't already contain.

Proposed fix

Skip OpenCode rows whose providerID is claude-code in the OpenCode reader (both the V2 session_message rows and the legacy message rows). Claude Code is still counted in full by its own provider, so nothing is lost. I'll open a PR with this and a regression test.

Activity

  1. added a commit that references this issue on Oct 16, 2026
    4090265
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions