Skip to content

fix(ai): include native Anthropic OAuth billing fingerprint - #1398

Open
chupe wants to merge 1 commit into
code-yeongyu:mainfrom
chupe:fix/anthropic-oauth-fingerprint
Open

fix(ai): include native Anthropic OAuth billing fingerprint#1398
chupe wants to merge 1 commit into
code-yeongyu:mainfrom
chupe:fix/anthropic-oauth-fingerprint

Conversation

@chupe

@chupe chupe commented Sep 5, 2026

Copy link
Copy Markdown

Summary

Adds the missing billing fingerprint to native Anthropic OAuth requests, together with the external CLI user-agent suffix and Agent SDK identity. The fingerprint uses the first serialized user text block and browser-safe SHA-256. The existing supported client version remains 2.1.251.

This is separate from the version-floor fix in #1289 and the stale version fixed in pi-anthropic-auth #60. The related OMO #3892 targeted OpenCode and closed without merging.

Behavior

  • Native OAuth requests include deterministic cc_version, cc_entrypoint=sdk-cli, and cch fields before payload hooks run.
  • Caller system blocks, cache checkpoints, metadata, and forced-tool-choice fallback retain their behavior.
  • Ordinary API-key, Cloudflare, and Copilot requests do not gain OAuth fields.
  • No dependency, lockfile, authentication-storage, or version-pin changes.

Verification

Check Result
New final-fetch regressions before the fix 14 expected failures, 3 adjacent passes
Focused OAuth suites 36 passed
Anthropic provider group 216 passed, 39 existing opt-in live cases skipped
Root bun run check Passed, including compiler and browser smoke
Telemetry build and AI build:offline Passed
Real source CLI, isolated OAuth fixture against localhost Exit 0; fingerprint hashes matched the serialized input; final marker returned
Real source CLI, isolated API-key fixture Exit 0; no billing block; caller system input preserved
Isolation Both sandboxes removed; real auth unchanged
Independent gate review APPROVE; eight real-SDK hash cases independently reproduced, including Unicode

Exact commands and sanitized receipts are retained locally under local-ignore/qa-evidence/20260905-oauth-upstream/ (red.txt, green.txt, cli-qa.json, README.md), excluded from Git per repository policy. The CLI proof uses the repository's Senpi QA sandbox and fake-model helpers.

Scope and risk

The change is confined to the native OAuth branch. Fingerprint input edge cases, payload-hook preservation, browser imports, and non-OAuth paths have regression coverage. No real provider credentials were used for these checks. LSP could not initialize with the installed TypeScript 7 tooling; the actual repository compiler passed.


Summary by cubic

Fixes native Anthropic OAuth requests being rejected for missing the deterministic billing fingerprint and external CLI/Agent SDK identity.

Adds a x-anthropic-billing-header system block (cc_version, cc_entrypoint=sdk-cli, cch) derived from the first serialized user text block via browser-safe SHA-256, plus the (external, cli) user-agent suffix and Agent SDK identity. The block is prepended before payload hooks run, and only the native OAuth branch is affected; API-key, Cloudflare, and Copilot requests stay unchanged.

Bug Fixes

  • Preserves caller system blocks, cache checkpoints, metadata, and forced-tool-choice fallback behavior.
  • Keeps the supported Claude Code version at 2.1.251 with no dependency, lockfile, or auth-storage changes.
  • Adds regression coverage for fingerprint edge cases (string, text blocks, image-only, empty input) and all non-OAuth paths.

Written for commit 770262f. Summary will update on new commits.

Review in cubic

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.

1 participant