In #29792, once a provider and model had accepted `drop_block`, any 400
on a request with it retried once without it, since I didn't know what
error a provider returns for an unsupported beta. That turned out to
hide real errors. On dogfood, a chat replaying some very tall
screenshots hit Anthropic's many-image limit:
```
messages.9.content.43.image.source.base64.data: At least one of the image dimensions exceed max allowed size for many-image requests: 3000 pixels
```
The retry without `drop_block` then hit the stale thinking block, so the
chat failed with the binding error instead, and the image error only
showed up in a warn log.
To fix, we'll only retry without `drop_block` when the 400 is a known
rejection of the field or its beta, and otherwise return the error as is
and keep the hint. The catch is that if a provider rejects the beta with
an error we don't recognise, chats on that model will see it until a
restart clears the hint, rather than us recovering.
Claude Code (as of 2.1.300) does the same on Anthropic's own API, Claude
Platform on AWS included: it only retries without the beta when the 400
names it or the `block_binding` field. On Bedrock, Vertex and Mantle it
also retries on any 400 it doesn't otherwise recognise, which we could
copy if that catch turns out to matter.
The oversized screenshots are a separate problem, since chatd doesn't
resize images at all.
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).
<details>
<summary>Testing</summary>
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.
</details>