Skip to content

Commit b109121

Browse files
ryoppippiigorovh
andcommitted
docs(opencode): note the limits of Claude Agent dedup
State that unified reports count Claude Agent turns under Claude only when Claude Code's own log has them, that a turn crossing midnight in the Claude source's timezone can be counted twice, and that only v2 session_message rows can carry the link, since OpenCode added the provider after moving to SQLite v2. Refs #2004 Co-authored-by: igorovh <[email protected]>
1 parent 18f6892 commit b109121

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎docs/guide/all-reports.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ ccusage detects local usage files from Claude Code, Codex, OpenCode, Amp, Droid,
4646

4747
Unified tables include an **Agent** column so you can compare sources in one view. Focused views remove that comparison layer and show the selected source in more detail where applicable.
4848

49-
When one tool runs another, usage can be logged by both. OpenCode's Claude Agent provider is one example: unified views count those turns once, under Claude. See [OpenCode](./opencode/#claude-agent-provider).
49+
When one tool runs another, usage can be logged by both. OpenCode's Claude Agent provider is one example: unified views count those turns once, under Claude, whenever Claude Code's own log has them. See [OpenCode](./opencode/#claude-agent-provider).
5050

5151
## Supported Sources
5252

‎rust/adapters/opencode/src/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ SQLite databases are the primary source. Legacy JSON messages under `storage/mes
1616

1717
OpenCode v2 forks copy the parent's `session_message` rows with new ids but the same `seq`. When `session_v2.fork_session_id` and `fork_boundary` resolve against the parent's rows, fork rows at or below the last copied `seq` (the boundary for `through`, the parent's last row before it for `before`) are skipped as inherited history. The fork's `session_v2` counters start at zero and hold only fork-local usage, so they remain a valid session fallback. Unresolvable boundaries and pre-`seq` schemas keep every row.
1818

19-
The Claude Agent provider (`claude-agent`) runs Claude Code, which also writes its own transcript. Its v2 rows record that Claude Code session as `content[].native.sessionID`, which `load_entries_with_native_sessions` returns with each entry. Unified reports drop a row when the Claude source counted main-thread usage of that session on the row's date, in the Claude source's timezone and date range, so the usage is counted once and priced by the resolved model ID rather than the `opus`/`sonnet` alias OpenCode stores. The match is per session day, not per turn: `native.messageID` is the transcript line `uuid`, and one OpenCode row sums several API calls, so rows do not map one-to-one to Claude entries. This relies on the transcript holding every main-thread turn OpenCode records for that session; it also holds turns OpenCode drops, such as interrupted steps saved with `tokens: null`. `ccusage opencode` keeps every row.
19+
The Claude Agent provider (`claude-agent`) runs Claude Code, which also writes its own transcript. Its v2 rows record that Claude Code session as `content[].native.sessionID`, which `load_entries_with_native_sessions` returns with each entry. Unified reports drop a row when the Claude source counted main-thread usage of that session on the row's date, in the Claude source's timezone and date range, so the usage is counted once and priced by the resolved model ID rather than the `opus`/`sonnet` alias OpenCode stores. The match is per session day, not per turn: `native.messageID` is the transcript line `uuid`, and one OpenCode row sums several API calls, so rows do not map one-to-one to Claude entries. This relies on the transcript holding every main-thread turn OpenCode records for that session; it also holds turns OpenCode drops, such as interrupted steps saved with `tokens: null`. A row is dated by its turn's start while Claude dates each call, so a turn that crosses midnight in the Claude source's timezone can be counted by both sources when Claude has no usage of that session on the earlier day. Only v2 `session_message` rows can carry the link: OpenCode added the provider after moving to SQLite v2, so legacy JSON messages and the v1 `message` table hold no `claude-agent` rows. `ccusage opencode` keeps every row.
2020

2121
Token mapping:
2222

0 commit comments

Comments
 (0)