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
omarchy-agent-usage-claude is meant to count Claude usage from opencode sessions on the anthropic provider (scan_opencode_usage). With opencode v2 none of it gets counted: the Claude record shows no opencode tokens, even after omarchy agent usage update --force.
Cause
scan_opencode_usage only reads the legacy v1 table and expects the v1 row shape (data.role == "assistant", top-level data.providerID / data.modelID):
conn.execute("SELECT session_id, data FROM message")
opencode v2 writes messages to session_message instead, and the shape is different:
The role is in the type column ('assistant'), not in data.role.
Provider and model are nested: data.model.providerID and data.model.id (plus variant).
data.tokens has the same shape as before (input, output, reasoning, cache.read, cache.write), and data.time.created is still in ms.
Example session_message.data for an assistant row (with content removed):
In ~/.local/share/opencode/opencode.db on this machine:
message (legacy): 67 rows, none of them on anthropic, so the scan finds nothing.
session_message (v2): 20 assistant rows on anthropic / claude-opus-5-5 (~1.14M cache-read, ~72K cache-write, ~5.4K output and ~3.2K reasoning tokens). None of these show up in the panel.
session_v2 also has per-session totals (tokens_input, tokens_output, tokens_reasoning, tokens_cache_read, tokens_cache_write) and a model JSON column, if those are easier to use.
Steps to reproduce
Use opencode v2 with the Anthropic provider (Claude subscription login) for a few prompts.
Run omarchy agent usage update --force.
Open the Agents panel, or look at ~/.local/state/omarchy/agents/usage/claude.json. None of the opencode tokens appear under "Tokens by day" or "Tokens by model", and they aren't included in totalPrompts.
Expected
opencode v2 Anthropic messages are counted the same way v1 messages are.
Side effect: if opencode v2 is the only Claude client in use and Claude Code's own sign-in has lapsed (so there are no limits), the Claude record has no data at all and the Agents icon disappears from the bar completely.
Possible fix
Also read session_message when it exists (WHERE type = 'assistant', provider from data.model.providerID, model from data.model.id). Keep the message scan for v1 databases.
Checked against master: bin/omarchy-agent-usage-claude still only queries FROM message (line 476).
The opencode v2 Claude-usage fix from #13894 was incorporated into #14049, now merged into quattro. The collector reads session_message rows and their nested provider/model fields, so the reported Anthropic usage is counted again. This report is already closed; this records the landed replacement for the original fix PR.
Closure scope checked by GPT-6 in Codex and Codex Medium against the reports and landed source. The second opinion agreed; independence is not guaranteed. No runtime tests were rerun for this reconciliation.
Activity
jandrusk commentedon Oct 1, 2026
Clear diagnosis. Fix PR already open: #13894 (“Count Claude usage from opencode v2 sessions”) — reads
session_message, normalises the v2 shape, and keys v2 sessions asopencode-v2:<id>. Suggest linking / closing this issue when #13894 merges.omarchybot commentedon Oct 4, 2026
The opencode v2 Claude-usage fix from #13894 was incorporated into #14049, now merged into
quattro. The collector reads session_message rows and their nested provider/model fields, so the reported Anthropic usage is counted again. This report is already closed; this records the landed replacement for the original fix PR.Closure scope checked by GPT-6 in Codex and Codex Medium against the reports and landed source. The second opinion agreed; independence is not guaranteed. No runtime tests were rerun for this reconciliation.