Skip to content

Claude collector: attribute pi usage by provider, not api prefix - #6655

Merged
dhh merged 1 commit into
omacom:quattrofrom
dalmasluca:fix/claude-agent-pi-provider-filter
Aug 9, 2026
Merged

dhh merged 1 commit into
omacom:quattrofrom
dalmasluca:fix/claude-agent-pi-provider-filter

Conversation

@dalmasluca

@dalmasluca dalmasluca commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The Claude usage tab shows buckets for models that are not Claude at all.

On a machine without a Claude login, the bar still appeared with Kimi k3 / k3-256k values under the "Claude Code" label, charged entirely from local pi sessions.

Root cause

omarchy-agent-usage-claude's pi/omp scan included any session whose api field merely started with anthropic:

if provider != "anthropic" and not api.startswith("anthropic"):
    continue

Kimi and other providers that speak the anthropic-messages protocol (provider: kimi-coding, api: anthropic-messages) were therefore attributed to Claude Code. Since the panel shows anything where totalPrompts > 0, a non-logged-in Claude still rendered a tab full of foreign models.

Falling back to api also risked counting a third-party router that presents an anthropic-style api but is not this subscription — the same class of bug the codex collector already avoids by matching provider == "openai-codex" exactly.

Change

Match the codex collector's provider-only attribution: count a pi/omp session toward Claude usage only when provider == "anthropic".

if provider != "anthropic":
    continue

Test

Adds a case to agent-usage-claude-scanner-test.sh: a kimi-coding-provider session using api: anthropic-messages (model k3) must be excluded from the Claude record, keeping .todayTotalTokens == 49 and .modelUsage free of the k3 bucket.

Pi/omp sessions kept falling into the Claude record when the api
field merely started with 'anthropic'. Kimi and other providers that
speak the anthropic-messages protocol (kimi-coding) were therefore
charged against Claude Code, showing k3 buckets under a Claude tab
even for a user without a Claude login.

Match the codex collector's provider-only attribution: only sessions
whose provider is exactly 'anthropic' count toward Claude usage.

Add a test proving a kimi-coding session sharing the
anthropic-messages api does not land in the Claude record.
Copilot AI balanced review requested due to automatic review settings August 9, 2026 11:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restricts Claude usage attribution to sessions explicitly using the Anthropic provider, preventing compatible third-party APIs from appearing as Claude usage.

Changes:

  • Removes API-prefix fallback attribution.
  • Adds regression coverage for Kimi sessions using the Anthropic protocol.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.

File Description
bin/omarchy-agent-usage-claude Requires the exact anthropic provider.
test/shell.d/agent-usage-claude-scanner-test.sh Verifies Kimi usage is excluded.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@dhh
dhh merged commit 2a0c737 into omacom:quattro Aug 9, 2026
dalmasluca pushed a commit to dalmasluca/omarchy that referenced this pull request Aug 9, 2026
Pi/omp sessions were attributed to Codex when the api field merely
started with 'openai-codex'. A third-party router that serves the same
gpt models behind an openai-codex-style api was therefore charged to
this subscription and added its buckets to the Codex record.

Keep attribution strict to the provider, matching the codex scanner
guidance and the Claude collector fix (omacom#6655): only sessions whose
provider is exactly 'openai-codex' count.

Add a regression test where a third-party-router session using the
openai-codex-responses api must not land in the Codex record.
nick1udwig pushed a commit to nick1udwig/omarchy that referenced this pull request Sep 9, 2026
…com#6655)

Pi/omp sessions kept falling into the Claude record when the api
field merely started with 'anthropic'. Kimi and other providers that
speak the anthropic-messages protocol (kimi-coding) were therefore
charged against Claude Code, showing k3 buckets under a Claude tab
even for a user without a Claude login.

Match the codex collector's provider-only attribution: only sessions
whose provider is exactly 'anthropic' count toward Claude usage.

Add a test proving a kimi-coding session sharing the
anthropic-messages api does not land in the Claude record.

Co-authored-by: Luca <luca@itwasarch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants