Skip to content

Drop mismatched Claude thinking blocks for Posit AI Pass provider - #190

Merged
wch merged 1 commit into
mainfrom
positai-thinking-binding
Nov 12, 2026
Merged

wch merged 1 commit into
mainfrom
positai-thinking-binding

Conversation

@wch

@wch wch commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

Claude 5.5-generation models (Fable 5.1, Opus/Sonnet/Haiku 5.5) bind each thinking block that PA replays in a later turn to the conversation content in front of it. If that earlier content changes, for example because a user message was edited, Anthropic either rejects the request with 400 "The block is bound to a different conversation" (on accounts where it enforces the binding) or, if the request opts in, drops the mismatched blocks and lists them in the response's input_transformations. Since #138, PA opts in on every Claude route by sending thinking.block_binding.prefix_mismatch_behavior: "drop_block" with the beta header thinking-binding-controls-2026-08-01. Posit AI Pass was the exception: its gateway rejected the beta with 400 "disallowed Anthropic-Beta value", so ai-provider-bridge left the binding off for that route.

The gateway now accepts both the beta and the body field (prism-gateway #354, releases 2026.10.20-1 and later) and passes the response through unchanged, so input_transformations reaches PA's existing warning. This PR sends the binding over Posit AI Pass too, so edited history is handled the same way as on the other Claude routes. The monorepo companion PR (anthropic-drop-blocks) only moves the ai-lib pointer to this commit.

How the binding is decided

The host decides which models get drop_block (resolveThinkingBlockBinding in packages/node). The function that builds the Anthropic request options for every Claude client, anthropicRequestOptions in ai-provider-bridge/src/utils.ts, attached that binding unless the client's transport was in an exclusion set whose only member was positai. Removing Posit AI Pass would leave the set empty, so this PR removes the mechanism: the set, the transport parameter, and the transport argument each of the five Claude clients passed. The bridge now attaches the host's binding whenever thinking is adaptive:

const blockBinding = isThinkingEnabled(effort) ? request.blockBinding : undefined;

As before, thinking "Off" and the provider-default effort send no binding.

What to watch for

  • Mismatched thinking blocks on Posit AI Pass are now dropped instead of kept. The staging gateway's Anthropic account does not enforce the binding, so without drop_block Anthropic keeps a mismatched block and reports it as thinking_mismatch_allowed; Posit AI Pass users were not getting the 400 on staging. Dropping matches the other Claude routes and keeps Posit AI Pass working if Anthropic later enforces the binding for the gateway's account. Anthropic notes that a drop can increase output tokens. The prompt cache is already invalid from the changed content onward, so caching is no worse.

  • The production gateway's release is unconfirmed. Only staging was tested, and we don't know which release production runs. If it is older than 2026.10.20-1, it rejects the beta, and every Posit AI Pass request to these models with adaptive thinking fails.

Validation

Headless TUI against the Posit AI Pass staging gateway with positai/claude-opus-5-5 and raw HTTP capture:

  1. First turn: 200, with the beta header and block_binding: drop_block in the request.
  2. Second turn, replaying a signed thinking block: 200, input_transformations: [].
  3. After editing the first user message in the stored conversation: 200, with thinking_dropped for both replayed blocks (prefix_binding_mismatch), and PA logged its input_transformations warning.
  4. Same conversation with the dev override PA_THINKING_BLOCK_BINDING=header-only (beta header, no body field): 200, with thinking_mismatch_allowed for both blocks, which shows the staging account is not enforced.

The ai-lib type check, format check, bridge lint and full bridge test suite pass. As before, the binding has no live verification on Bedrock, Vertex or Snowflake.

Alternatives considered

Remove only positai and keep the empty exclusion set for future proxies that reject the beta. Not taken: it would leave an unused parameter threaded through five clients. If a transport later rejects the beta, the exclusion can come back in that client or as a parameter again.

The Posit AI gateway now accepts the thinking-binding-controls-2026-08-01
beta and thinking.block_binding (prism-gateway #354), so Posit AI
requests to prefix-checked Claude models carry drop_block like every
other Anthropic Messages route. A prefix change now drops replayed
thinking instead of returning 400.

Posit AI was the only transport in TRANSPORTS_WITHOUT_BLOCK_BINDING, so
remove the veto set, the AnthropicTransport type and the transport
parameter of anthropicRequestOptions.

Verified live against the staging gateway with Opus 5.5: a forced prefix
change returned 200 with thinking_dropped entries in
input_transformations.
@wch
wch merged commit 9c1267b into main Nov 12, 2026
4 checks passed
@wch
wch deleted the positai-thinking-binding branch November 12, 2026 19:52
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