GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: retry Anthropic thinking binding errors with drop_block by ethanndickson · Pull Request #29792 · coder/coder

Conversation

@ethanndickson

@ethanndickson ethanndickson commented Sep 23, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Closes CODAGT-1141

Opus 5.5 and Fable 5.1 bind each signed thinking block to the exact prefix it was created under. chatd rebuilds the system prompt and tools from live state before every model call, so if that state changes mid-turn (e.g. after start_workspace), the replayed block no longer matches and Anthropic returns a 400, which we treated as non-retryable:

messages.1.content.0: Invalid `signature` in `thinking` block. The block is bound to a different conversation...

To fix, we'll do what Anthropic recommends: on that 400, retry once with thinking.block_binding.prefix_mismatch_behavior: "drop_block" and the thinking-binding-controls-2026-08-01 beta, then send both upfront for that provider and model once the retry succeeds. That's only a hint, since BYOK users on the same provider can have different keys, so if a request with drop_block gets a 400 we retry once without it and clear the hint. The retry wraps the model itself, so compaction and the advisor get it too. The hint is in-memory, so a restart costs one extra 400 per model on each replica. Chats that never hit the error are unchanged.

aibridge's InvokeModel path was stripping the beta and deleting block_binding, so it now forwards both or neither, for any model. It also renames the field to mismatch_behavior, since that's what Bedrock calls it, and only some regions accept the Anthropic name.

Always sending drop_block would change bytes on working chats, and AWS doesn't document Mantle support for the beta. Dropping stale thinking client-side means guessing what the server will reject (the signature is opaque, and enforcement depends on the model and account), so it would still need the retry. The proper fix is an append-only prefix, but that's a much bigger change, and it would also still need this retry.

Mantle does accept the beta, at least for Opus 5.5 on us-east-1 (see testing below).

Testing

I tested this manually on 9c2b4d6 with develop.sh, using Opus 5.5 on Bedrock Mantle us-east-1 via the dogfood AI Gateway, with a small logging proxy in front to record the beta header and block_binding on each request. The direct Anthropic API doesn't enforce the binding for our account, so I couldn't reproduce it there.

To trigger it, I just asked the agent to reason about something, create a workspace from the docker template and run a command in it, all in one turn. On the merge base, the turn fails with the 400 above as soon as the workspace is created. On this branch there's one 400, the drop_block retry succeeds, the turn finishes with no error in the UI, and every request after that sends drop_block upfront:

status=400 beta=""                                     block_binding=""
status=200 beta="thinking-binding-controls-2026-08-01" block_binding={"prefix_mismatch_behavior":"drop_block"}
status=200 beta="thinking-binding-controls-2026-08-01" block_binding={"prefix_mismatch_behavior":"drop_block"}

The chat that failed on the merge base also recovers once it's continued on this branch, and a restart costs one extra 400 as expected. I also had the proxy reject any request with drop_block, to mimic a BYOK key without the beta, and the retry without it succeeded and cleared the hint, so the next chat didn't send it.

I didn't test the InvokeModel path, since I don't have AWS credentials for it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chatgpt-codex-connector[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@ethanndickson
fix: retry Anthropic thinking binding errors with drop_block
d1dfcc0
Opus 5.5 and Fable 5.1 bind signed thinking blocks to the exact prefix.
chatd rebuilds the system prompt and tools before each call, so a
mid-turn state change makes Anthropic reject replayed thinking with a
400. On that error, retry once with the thinking-binding-controls beta
and prefix_mismatch_behavior "drop_block", then keep sending both for
the chat and model config.

aibridge InvokeModel now forwards the beta and block_binding together,
or strips the field when the beta is absent.
@github-actions github-actions Bot assigned ethanndickson Sep 23, 2026
@linear-code

linear-code Bot commented Sep 23, 2026

Copy link
Copy Markdown

CODAGT-1141

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ethanndickson added 2 commits September 23, 2026 14:41
@ethanndickson
fix: stop gating the Bedrock thinking binding beta by model
4a4ee0d
aibridge removed thinking-binding-controls-2026-08-01 for every Bedrock
model except Opus 5.5 and Fable 5.1, so each new model that enforces
thinking block binding needed a code change. Clients send the beta only
to models that need it, so forward it for any model.

Bedrock names the field thinking.block_binding.mismatch_behavior. Some
regions reject the Anthropic name, prefix_mismatch_behavior, so
InvokeModel now renames it.

chatd now tracks drop_block per chat and model config. A binding error
in compaction with an override model turns on drop_block for the
override config only, and the main model config no longer turns it on
for the override.
@ethanndickson
test(coderd/x/chatd): trim thinking binding tests
b1a14cd
@ethanndickson

ethanndickson commented Sep 23, 2026

Copy link
Copy Markdown
Member Author

@codex review

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 23, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-24T04:01:10.066992Z 9c2b4d6 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chatgpt-codex-connector[bot]
chatgpt-codex-connector Bot reviewed Sep 23, 2026
View reviewed changes

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

Copy link
Copy Markdown

There was a problem hiding this comment.

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: b1a14cdb9c

ℹ️ 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".

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread coderd/x/chatd/thinking_binding.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ethanndickson
fix(coderd/x/chatd): remember thinking drop_block per provider and model
c634f72
Move the thinking binding retry into a model decorator applied in
resolveModelCall, so turns, computer use, compaction, and the advisor
all get it. The decorator records a provider and model only after a
drop_block retry succeeds, which bounds the in-memory set to configured
models instead of growing with every chat.
@ethanndickson

ethanndickson commented Sep 24, 2026

Copy link
Copy Markdown
Member Author

@codex review

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chatgpt-codex-connector[bot]
chatgpt-codex-connector Bot reviewed Sep 24, 2026
View reviewed changes

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

Copy link
Copy Markdown

There was a problem hiding this comment.

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: c634f7260c

ℹ️ 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".

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread coderd/x/chatd/thinking_binding.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ethanndickson
fix(coderd/x/chatd): treat thinking drop_block acceptance as a hint
9c2b4d6
The cached provider and model entry only picks which request goes
first. With the hint set, drop_block is sent first and any 400 before
output retries once without it, clearing the hint if that succeeds.
BYOK keys, key rotation, or a gateway that rejects the beta now cost
one extra 400 instead of failing every request until restart.
@ethanndickson

ethanndickson commented Sep 24, 2026

Copy link
Copy Markdown
Member Author

@codex review

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 24, 2026

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 9c2b4d61b0

ℹ️ 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".

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ethanndickson
ethanndickson marked this pull request as ready for review September 24, 2026 03:30
chatgpt-codex-connector[bot]
chatgpt-codex-connector Bot reviewed Sep 24, 2026
View reviewed changes

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

Copy link
Copy Markdown

There was a problem hiding this comment.

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: 9c2b4d61b0

ℹ️ 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".

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread coderd/x/chatd/thinking_binding.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ethanndickson

ethanndickson commented Sep 24, 2026

Copy link
Copy Markdown
Member Author

@codex review

Reset the stream watchdog before opening the fallback

Fair, but I don't think it's worth the extra plumbing here. The fallback only loses however long the first 400 took, which is normally a second or two against a 10 minute default, and if the guard does fire it's classified as retryable, so chatd just runs a fresh attempt with a fresh guard. If we end up with more in-attempt retries like this I'd rather add a proper activity hook to guardedStream in its own PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 24, 2026

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 9c2b4d61b0

ℹ️ 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".

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ibetitsmike
ibetitsmike approved these changes Sep 24, 2026
View reviewed changes
@ibetitsmike

ibetitsmike commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

LGTM

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ethanndickson
ethanndickson merged commit 0e9337c into main Sep 24, 2026
44 of 45 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@ethanndickson
ethanndickson deleted the chatd-sk74 branch September 24, 2026 04:02
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 24, 2026
johnstcn
johnstcn reviewed Sep 24, 2026
View reviewed changes

@johnstcn johnstcn left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

cc @pawbana -- this is probably not going to be necessary with passthrough mode

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ethanndickson ethanndickson added the backport label Oct 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@johnstcn johnstcn johnstcn left review comments
@chatgpt-codex-connector chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] left review comments
@ibetitsmike ibetitsmike ibetitsmike approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@ethanndickson ethanndickson

Labels

backport

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@ethanndickson @ibetitsmike @johnstcn
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.