Repository navigation
Conversation
#4584 Signed-off-by: Arnaud Héritier <aheritier@apache.org>
Signed-off-by: Arnaud Héritier <aheritier@apache.org>
- Drop the Fable example from the server-side fallback comment; that configuration is now rejected. - Build the Bedrock Mantle-only error from the configured model ID. - Move unit-test fixtures off Claude 5.x fallbacks that the constructor now rejects. Signed-off-by: Arnaud Héritier <aheritier@apache.org>
Reasoning was flattened into one string and the last signature, and redacted bytes were stored in the signature string, where JSON persistence corrupted them. Record every content block by index and emit the ordered blocks as ProviderState on a complete message. Signed-off-by: Arnaud Héritier <aheritier@apache.org>
Replay the recorded Converse blocks when the message still matches them, so interleaved, multi-signature and redacted reasoning round-trips exactly. The flattened fallback now sends signed thinking with empty text as reasoning text instead of redacted content. Signed-off-by: Arnaud Héritier <aheritier@apache.org>
Signed-off-by: Arnaud Héritier <aheritier@apache.org>
Signed-off-by: Arnaud Héritier <aheritier@apache.org>
Bedrock messages now carry a ProviderState, and the Anthropic converters only replayed flattened thinking when the state was nil. After a fallback or a model switch from Bedrock, the thinking block was dropped and the tool loop was rejected. Only Anthropic's own state suppresses it. Signed-off-by: Arnaud Héritier <aheritier@apache.org>
Thinking cut off by max_tokens, or another vendor's reasoning on Bedrock, has no signature the API can verify. Skip it on replay, as the Anthropic path does, while keeping it in the message match. Signed-off-by: Arnaud Héritier <aheritier@apache.org>
Base automatically changed from
feat/claude5x-safety-defaults
to
feat/claude5x-model-table
October 20, 2026 08:47
Collaborator
Author
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Per-delta string concatenation introduces quadratic allocation overhead for long Bedrock text and reasoning streams.
1 open issue
What changed in this PR
Adds native Bedrock reasoning capture and replay through the existing provider-state mechanism, supporting the signed-history work in #4653.
Changes:
- Preserves ordered reasoning, redacted bytes, text, and tool calls across persistence.
- Updates flattened replay and Anthropic handling of foreign provider state.
- Includes Claude 5.x safety checks, regression tests, and documentation.
| File | Description |
|---|---|
| pkg/session/provider_state_persist_test.go | Tests opaque-byte persistence. |
| pkg/modelinfo/claude5.go | Marks Mythos 5 as Mantle-only. |
| pkg/modelinfo/claude5_test.go | Tests updated model metadata. |
| pkg/model/provider/bedrock/roundtrip_test.go | Tests streamed-state replay after serialization. |
| pkg/model/provider/bedrock/native_blocks.go | Records and replays ordered native blocks. |
| pkg/model/provider/bedrock/native_blocks_test.go | Tests replay and fallback behavior. |
| pkg/model/provider/bedrock/convert.go | Uses native replay and fixes signed-empty fallback. |
| pkg/model/provider/bedrock/client.go | Rejects Mantle-only Mythos 5. |
| pkg/model/provider/bedrock/client_test.go | Tests signed-empty replay and model rejection. |
| pkg/model/provider/bedrock/adapter.go | Captures native state from stream events. |
| pkg/model/provider/bedrock/adapter_test.go | Tests recording and incomplete streams. |
| pkg/model/provider/anthropic/vertex/vertex_test.go | Tests Claude 5.x fallback rejection. |
| pkg/model/provider/anthropic/thinking_test.go | Adjusts display-validation fixtures. |
| pkg/model/provider/anthropic/thinking_binding.go | Adds fallback validation. |
| pkg/model/provider/anthropic/thinking_binding_test.go | Adjusts binding test fixtures. |
| pkg/model/provider/anthropic/response_content.go | Identifies Anthropic-owned state. |
| pkg/model/provider/anthropic/features_integration_test.go | Tests safety checks and foreign-state thinking. |
| pkg/model/provider/anthropic/fallbacks.go | Rejects Claude 5.x fallback chains. |
| pkg/model/provider/anthropic/fallbacks_test.go | Tests fallback validation. |
| pkg/model/provider/anthropic/client.go | Preserves flattened thinking for foreign state. |
| pkg/model/provider/anthropic/beta_converter.go | Applies foreign-state handling to beta requests. |
| examples/anthropic-fallbacks.yaml | Uses a supported fallback chain. |
| docs/providers/bedrock/index.md | Documents native replay and model restrictions. |
| docs/providers/anthropic/index.md | Documents fallback restrictions. |
| agent-schema.json | Updates fallback option documentation. |
Review effort: Balanced
| switch d := d.(type) { | ||
| case *types.ContentBlockDeltaMemberText: | ||
| b := r.get(idx, "text") | ||
| b.block.Text += d.Value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Part (a) of #4653: Bedrock native reasoning blocks. Part of #4583 and epic #4580. Parts (b) and (c) follow as separate stacked PRs (see the plan in #4653).
What
Bedrock Converse now captures, persists and replays Claude's reasoning blocks exactly, instead of flattening them into one string and one signature.
ContentBlockIndex(reasoning text and signature, redacted bytes, text, tool use). When a message completes, it attaches the ordered blocks asProviderState{provider: "amazon-bedrock"}. Incomplete or failed streams record nothing.convertAssistantContentrebuilds the recorded blocks in order when the message still matches them: same text, reasoning and tool calls, compared with the runtime's own accumulation rules. Otherwise it falls back to the flattened fields.ProviderStatefor any provider. Nothing changes there.Bugs fixed (each with a test that failed first)
ThinkingSignature, a string; JSON replaced non-UTF-8 bytes on saveTwo regressions found in review and fixed before opening this PR:
ProviderStatewas present; now only Anthropic's own state suppresses it (e623364).max_tokens, or another vendor's reasoning on Bedrock) is never replayed, matching the Anthropic replay path (88f0a77).Compatibility
ThinkingSignature. The fallback now treats them as signed thinking, the common case on Claude 5. A legacy session that held genuinely redacted thinking would get a 400 on replay; those bytes were usually already corrupted by JSON.References
Vendor documentation behind each change (all links checked on 2026-10-20):
reasoningText(text + signature) vsredactedContent(bytes)contentBlockIndexin stream eventsValidation
task buildpasses.task testpasses. The 10 GeminiTestLoadExamplesfailures seen in earlier PRs didn't appear in this run.golangci-lintv2.14.0 reports 0 issues, andgo run ./lint .reports no offenses.go test -race -shuffle=onpasses onpkg/model/provider/bedrock,pkg/sessionandpkg/runtime.go test ./e2e -run '^TestWasmProviderDependencies$|^TestDependencies$'passes.Deferred minor findings:
ProviderState, including replies without reasoning.Not verified against live AWS: replay of native blocks on Converse.