Repository navigation
[STALE: REBASE FROM NEW FORK] feat(usage): log agentId from x-claude-code-agent-id - #16
Draft
vadymhimself wants to merge 1 commit into
Draft
vadymhimself wants to merge 1 commit into
vadymhimself wants to merge 1 commit into
Conversation
|
✅ Deterministic PR hygiene checks passed. |
⏳ DRAFT
What to do
Its title has been prefixed with |
…es rows
Claude Code subagents and teammates share the parent's session id and
metadata.user_id, so conversationId cannot attribute their tokens. The
x-claude-code-agent-id header is the one per-agent signal; log it as
agentId (shape ^a[\w-]{1,80}$), absent on the main agent or a bad value.
Co-Authored-By: Claude Code <noreply@anthropic.com>
vadymhimself
force-pushed
the
ops-low-r/gw-agent-id
branch
from
November 10, 2026 16:40
8888251 to
895ea81
Compare
vadymhimself
changed the base branch from
main
to
release/2.65.0-vadymhimself.15
November 10, 2026 16:40
Collaborator
Author
|
This PR is based on the superseded 2.65 gateway line. Rebuild the change from |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds one field,
agentId, to Claude/v1/messagesusage rows (usage.jsonl and /api/logs), taken from thex-claude-code-agent-idheader.Why: Claude Code subagents and teammates send the parent's
x-claude-code-session-idandmetadata.user_id, soconversationIdcannot attribute their tokens (one conversation showed opus and sonnet rows). Probed locally against a fake server: only subagent requests carryx-claude-code-agent-id(a+ 16 hex); the main agent does not.agentIdFromHeaders(request-log-conversation.ts): value must match^a[\w-]{1,80}$, else absent.Test: one case in tests/claude-integration/claude-native-passthrough.test.ts (no header / valid / malformed, checked in /api/logs and in the persisted rows); fails without the src change.
bun teston that file + usage-log + request-log-conversation: 84 pass (on release/2.65.0-vadymhimself.15);bun x tsc --noEmitclean. No deploy or gateway roll in this PR.🤖 Generated with Claude Code