Skip to content

fix(claude): gate block binding beta on final body - #5411

Open
papajade55-debug wants to merge 1 commit into
router-for-me:devfrom
papajade55-debug:fix/anthropic-beta-block-binding
Open

fix(claude): gate block binding beta on final body#5411
papajade55-debug wants to merge 1 commit into
router-for-me:devfrom
papajade55-debug:fix/anthropic-beta-block-binding

Conversation

@papajade55-debug

Copy link
Copy Markdown

Summary

  • add thinking-binding-controls-2026-08-01 only for first-party Anthropic requests whose final serialized body contains an object-valued thinking.block_binding
  • skip the beta when thinking.type is disabled, and do not enable it from caller headers or body.betas alone
  • use one deterministic parser for case-insensitive, multi-value/CSV Anthropic-Beta handling in both Claude client detection and request forwarding
  • canonicalize CPA-owned beta tokens and collapse mixed-case duplicates without reordering existing tokens
  • cover non-streaming, streaming, count_tokens, forced tool choice, custom gateways, and duplicate/header edge cases

Why

Anthropic rejects thinking.block_binding unless the matching beta is present. The request pipeline can add or remove thinking fields before serialization, so the header must be derived from the exact final body sent upstream rather than from the original caller request.

The shared header parser also prevents client detection and forwarding from observing different beta lists when a hand-built http.Header contains multiple case spellings.

Validation

  • go test ./... -count=1
  • go test -race on the changed executor and helper paths
  • go vet ./internal/runtime/executor/...
  • go build ./cmd/server
  • gofmt and git diff --check

All checks pass locally with Go 1.26.5.

@github-actions
github-actions Bot changed the base branch from main to dev September 2, 2026 05:27
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

This pull request targeted main.

The base branch has been automatically changed to dev.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: da1b2efabc

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +454 to 455
if beta = strings.ToLower(strings.TrimSpace(beta)); beta != "" {
requested[beta] = true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Canonicalize advisor beta casing before inserting it

When a caller-owned first-party request supplies only a casing variant such as ADVISOR-TOOL-2026-03-01, lowercasing it here makes advisorNeeded true, but the subsequent withClaudeAdvisorToolBeta comparison remains case-sensitive. It therefore preserves the unrecognized uppercase token and inserts a second canonical token, leaving Anthropic an invalid extra beta that can cause the request to be rejected. Canonicalize and deduplicate the advisor beta case-insensitively, as is now done for fast mode and block binding.

Useful? React with 👍 / 👎.

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