Repository navigation
fix(anthropic): pair native beta schemas with effective headers - #7132
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 1
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 49c7773e7f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const sentBody = pairAnthropicBetaBody(wireBody, body, headers["anthropic-beta"], | ||
| domain?.firstPartyAnthropic === true, oauthToolNames); |
There was a problem hiding this comment.
Apply beta pairing to the count body
For a managed native route, this pairing is applied only while building the real /v1/messages request, while nativeMessagesCountBody still returns anthropicMessagesNativeWireBody(...).wireBody at src/server/messages-native.ts:1011 without the caller or effective beta header. Consequently, /count_tokens includes thinking.block_binding when the real request strips it because the beta is absent or rejected; conversely, an operator-configured context-management beta makes the real request restore context_management while counting omits it. Pass the effective beta inputs into the count path and apply the same reconciliation so token estimates describe the body that is actually sent.
Useful? React with 👍 / 👎.
|
✅ Deterministic PR hygiene checks passed. |
|
Maintainer integration into
|
Summary
thinking.block_bindingwhile PF-10 dropped its required beta, causing Anthropic'sExtra inputs are not permitted400. Closes Native Messages lane forwards thinking.block_binding but drops its beta → 400 Extra inputs are not permitted #7102.block_binding, accepts adaptive/enabled thinking, and permits header-only transformation diagnostics. Platform-specific beta transport is documented in beta headers. First-party OAuth uses the existing Messages schema allowance; no paid live credential probe was performed.Verification
bun test tests/adapters/anthropic/anthropic-beta-body-pairs.test.tsbefore implementation: 2 pass / 14 fail. After implementation, the new file and existing allowlist file: 33 pass / 0 fail.bun run typecheck— passed.bun test tests/adapters/anthropic/anthropic-beta-body-pairs.test.ts tests/adapters/anthropic/anthropic-beta-allowlist.test.ts tests/adapters/anthropic/anthropic-messages-passthrough.test.ts tests/adapters/anthropic/anthropic-messages-passthrough-oauth.test.ts tests/claude-integration/messages-native.test.ts— 172 pass / 0 fail.bun test tests/test-layout.test.ts tests/test-layout-tooling.test.ts tests/ci-workflows/file-size-ratchet.test.ts— 36 pass / 0 fail.bun run structure:check— passed (both affected structure documents remain within their 600-line budgets).bun run privacy:scan— passed.cd docs-site && bun install --frozen-lockfile && bun run build— passed; 577 pages, 81,200 internal links checked.bun run test:changed— 4,242 pass / 30 skip / 0 fail, across 187 files (exit 0). The shared-machine queue cleared; suite execution took 75.9 seconds.bun run testintentionally omitted: multiple triage worktrees share one 16-core machine, as required by this task's resource exception. The focused files exercise final serialized bodies/headers, key/OAuth, compatible/cloud destinations, beta diagnostics, source immutability, context-tool rewrites, and translated-lane isolation. Broader coverage remains with Ubuntu PR CI; no macOS/Windows workflow dispatched.Independent review round 1 (head
49c7773e7f328fdfa3e9454831eeae244cc94288):src/adapters/anthropic/beta-allowlist.tsandsrc/adapters/anthropic/passthrough.tsto the parent commit, then ranbun test tests/adapters/anthropic/anthropic-beta-body-pairs.test.ts: 2 pass / 14 fail. Restored HEAD and reran the same file: 16 pass / 0 fail. Working tree is clean.bun test tests/adapters/anthropic/anthropic-beta-body-pairs.test.ts tests/adapters/anthropic/anthropic-beta-allowlist.test.ts tests/adapters/anthropic/anthropic-messages-passthrough.test.ts tests/adapters/anthropic/anthropic-messages-passthrough-oauth.test.ts tests/claude-integration/messages-native.test.ts— 172 pass / 0 fail.bun test tests/test-layout.test.ts tests/test-layout-tooling.test.ts tests/ci-workflows/file-size-ratchet.test.ts tests/lab/core-lab-boundary.test.ts— 61 pass / 0 fail.bun run typecheck,bun run structure:check, andbun run privacy:scan— passed. Initial typecheck/setup attempt could not run because Bun's package postinstall had been skipped; rannode node_modules/bun/install.jsand then successfully executed the required commands. No dependency files changed.src/adapters/anthropic/passthrough.ts:318-319. The count helper's configuration shape differs, butestimateClaudeRequestTokens(src/server/claude-messages.ts:1653-1697) reads only system/messages/tools; neither paired configuration field contributes. Scratch probebun /tmp/review-7132-count.tscompared actual builder bodies withnativeMessagesCountBodyacross 32 key/OAuth, caller-beta, oversized-beta, and operator-beta combinations: all estimates equal. No user-visible count defect reproduced; avoided unrelated count-path refactoring.test:changed, per the explicit shared-machine constraint. Docs build was not repeated; this review changed no documentation source. Broader suite/docs-build verification remains with PR CI.gh pr checks 7132 --repo lidge-jun/opencodex): no failed checks; required Ubuntu test shards and other required jobs remain queued. Some metadata runs were cancelled with queued replacements. Review verdict: needs-more until required CI completes successfully; code review itself found no blockers.Checklist
Summary by CodeRabbit