From 2a0c7371a5cbfe1727215c58d5e6fd87877d3322 Mon Sep 17 00:00:00 2001 From: Luca <103841256+dalmasluca@users.noreply.github.com> Date: Sun, 9 Aug 2026 13:27:38 +0200 Subject: [PATCH] Claude collector: attribute pi usage by provider, not api prefix (#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 --- bin/omarchy-agent-usage-claude | 3 +-- test/shell.d/agent-usage-claude-scanner-test.sh | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/omarchy-agent-usage-claude b/bin/omarchy-agent-usage-claude index c01bab39..7805c4fa 100755 --- a/bin/omarchy-agent-usage-claude +++ b/bin/omarchy-agent-usage-claude @@ -374,8 +374,7 @@ def scan_pi_usage(max_age_seconds: float) -> dict[str, Any] | None: if entry.get("type") != "message" or message.get("role") != "assistant": continue provider = str(message.get("provider") or "") - api = str(message.get("api") or "") - if provider != "anthropic" and not api.startswith("anthropic"): + if provider != "anthropic": continue unique_key = f"{path}:{entry.get('id') or line_number}" if unique_key in seen: diff --git a/test/shell.d/agent-usage-claude-scanner-test.sh b/test/shell.d/agent-usage-claude-scanner-test.sh index 84beb807..e1407f3c 100644 --- a/test/shell.d/agent-usage-claude-scanner-test.sh +++ b/test/shell.d/agent-usage-claude-scanner-test.sh @@ -112,6 +112,7 @@ mkdir -p "$PI_HOME/.pi/agent/sessions/project" "$PI_HOME/.omp/agent/sessions/pro cat >"$PI_HOME/.pi/agent/sessions/project/pi.jsonl" <"$PI_HOME/.omp/agent/sessions/project/omp.jsonl" <