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 <luca@itwasarch>
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user