Bug: Claude Code's second User-Agent is unrecognised, so ~13% of its events label as Other
I maintainer di solito rispondono entro 1 giorno
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
What happens
Claude Code sends three distinct User-Agents on live traffic, and knownClients recognises only one. Measured from one laptop proxy's session store:
| User-Agent | Events | ParseUserAgent().Name |
|---|---|---|
claude-cli/2.1.233 (external, claude-vscode, agent-sdk/0.3.233) |
469 | claude-code ✅ |
claude-code/2.1.233 (claude-vscode, agent-sdk/0.3.233) |
70 | "" ❌ |
Claude-User (claude-code/2.1.233; +https://support.anthropic.com/) |
12 | "" — deliberate, see below |
The middle row is the bug: claude-code is a value in knownClients but never a key. ParseUserAgent looks the first product token up against the map's keys, and that token is claude-code, so the lookup misses and the traffic is unrecognised.
Why it matters
Those 70 events — ~13% of this capture's Claude Code traffic — pool into agentop's catch-all Other row in the AGENTS pane instead of claude-code, and their spend goes with them. pipeline.IsKnownAgent is false for them, so they are also excluded wherever that gates (core/cost/usage). Claude Code is the reference integration, so this is the one agent whose attribution was assumed correct.
Session attribution is unaffected — AffinityName() returns claude-code for all three, because its comment-scan fallback compares against canonical names and claude-code is one. So this is a labeling/aggregation bug, not a session-grouping one.
The third row is not a bug
Claude-User (claude-code/…) staying unrecognised is intentional, and AffinityName's doc comment explains why: reading an agent's name out of a comment into Name would move those rows to a different agent in the ledger and the AGENTS pane than the history beside them. Leave it as is.
Suggested fix
One entry:
"claude-cli": "claude-code",
"claude-code": "claude-code", // the Agent-SDK-shaped UA
I probed this locally and verified three things:
claude-code/2.1.233 (…)labels asclaude-code/ version2.1.233.Claude-User (claude-code/…)still does NOT label — its first token isClaude-User, andtrailingKnownClientcuts on/without trimming punctuation, so the later token reads as(claude-codeand misses. The deliberate behaviour survives.- The existing
core/pipelinesuite stays green.
Worth adding a TestParseUserAgent_* row for each of the three live UAs above, including the negative for Claude-User, so the deliberate case is pinned alongside the fixed one.
How this was found
While verifying Codex's agent recognition for #1337, which fixed the same class of bug for Codex: an agent that sends more than one product token, with the lookup table covering only some of them. Codex needed codex-tui and codex_cli_rs added beside codex_exec for exactly this reason. Worth a look at whether bob/bob-shell/opencode have unlisted second tokens too — OpenCode reportedly uses one UA for every mode, but that is from a source comment rather than a capture.
Not fixed in #1337 deliberately: that PR is Codex support, and this is a different agent.
Unknown
Whether headless Claude Code (claude -p) is one of these two shapes or a fourth. Both recognised shapes mention claude-vscode and agent-sdk, so they look like different components (CLI binary vs Agent SDK) rather than interactive-vs-headless, but I have no headless capture to confirm it.
Assisted-By: Claude (Anthropic AI) [email protected]
- Lingua principale
- Go
- Stelle
- 16
- Fork
- 41
- Merge medio
- 11h 11m
- PR unite (30g)
- 270
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di rossoctl/cortex
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
rossoctl/cortex#1116 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
Epic: Bring Codex to parity with Claude Code — cost, sessions, tool pruning, and the unverified surfaceForse già presa @Alan-Cha l’ha presa 1 giorno fa. Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 6/100
rossoctl/cortex#1365 · 5 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Serve the one-line installer from rossoctl.dev instead of raw.githubusercontent.comForse già presa @esnible l’ha presa 1 giorno fa. Apertaenhancement laptop ux
Difficoltà 5/5 Più di una settimana Idoneità per principianti 12/100
rossoctl/cortex#1354 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di rossoctl/cortex
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
copilot-api domain:platform go
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
docs: clarify gh api -f vs -F and @-file expansion in the gh skillForse già presa @MatiasOlivera l’ha presa oggi. Apertaenhancement
Difficoltà 2/5 Mezza giornata Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
aws/aws-advanced-go-wrapper#612 ·
-
Say in the changelog that the text-index update cannot be rolled backForse già presa @praetorianer777 l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
praetorianer777/GoTome#275 ·
I maintainer di solito rispondono entro 1 giorno