Repository navigation
Python: Fix Claude Opus 5.5 on Bedrock by skipping reasoningContent blocks - #14469
Lucas Kim (kimnamu) wants to merge 1 commit into
Conversation
…locks With no thinking settings, Claude Opus 5.5 (and Opus 5) on Bedrock send a reasoningContent block ahead of the text or toolUse blocks whenever the model decides to think; how often depends on the prompt. The Converse response parser raised ServiceInvalidResponseError on that block, and the streaming delta parser read the reasoning delta as toolUse (KeyError). Skip reasoningContent blocks in responses; other unknown blocks still raise. Stream deltas that are neither text nor toolUse now give an empty chunk, like _parse_content_block_start_event. Nothing is surfaced or sent back.
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved review issues were identified, and the regression tests pass.
Review effort: Lite
Findings: None
What changed in this PR
Fixes Bedrock Claude responses by safely ignoring reasoningContent blocks while preserving text and tool-call handling.
Changes:
- Skips reasoning blocks in non-streaming responses.
- Ignores unsupported reasoning deltas during streaming.
- Adds regression tests for both paths.
| File | Description |
|---|---|
python/tests/unit/connectors/ai/bedrock/services/test_bedrock_chat_completion.py |
Adds reasoning-content regression tests. |
python/semantic_kernel/connectors/ai/bedrock/services/bedrock_chat_completion.py |
Updates Bedrock response and stream parsing. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Eduard van Valkenburg (@eavanvalkenburg) Thank you for re-running Merge Gatekeeper on this PR on Sept 28, and for working through the Python PRs while SK isn't taking new features. This one fixes an error that is still on
When you have a moment, could you review it? If this isn't a priority right now, tell me and I'll close it to keep your queue clean. |
Motivation and Context
Thanks to the Python team for the Bedrock connector (#9100) and #12395, which let the Claude Opus 5.5 profile IDs load unchanged.
Fixes #14468
With no thinking settings, Claude Opus 5.5 (and Opus 5) on Bedrock send a
reasoningContentblock first whenever the model decides to think. How often depends on the prompt (Opus 5.5, rawconverse: "Weather in Paris? brief" 5/5, "Hello" 0/5).BedrockChatCompletionthen raises (non-streaming) or reads the reasoning delta astoolUse(streaming).main)us.anthropic.claude-opus-5-5, "Weather in Paris? brief", non-streamingServiceInvalidResponseError: Unsupported content type ... reasoningContentKeyError: 'toolUse'global.anthropic.claude-opus-5-5, both modesus.anthropic.claude-opus-5, both modesAuto(auto_invoke=False), model thinks before the tool callsServiceInvalidResponseErrorTOOL_CALLSAuto()auto-invoke, model thinks after the tool resultServiceInvalidResponseErrorSTOPParallel tool calls with auto-invoke still fail with
Expected toolResult blocks at messages.2.content. That is #14073 (fix in #14074); it also fails onmainwith Opus 5 and no reasoning block.Description
_create_chat_message_content: skipreasoningContentnext to thetext/image/toolUsebranches (theelseat L257 raised). Other unknown blocks still raise._parse_content_block_delta_event: builditemswithif/eliflike_parse_content_block_start_event. Deltas that are neithertextnortoolUse(reasoningContent,citation) now give an empty chunk instead of an accidentalKeyErroron["toolUse"](L346-348).The Anthropic connector also reads only
TextBlockand tool-use blocks (anthropic_chat_completion.pyL267-269). SurfacingReasoningContentwould need_format_assistant_messageto send it back with its signature; left for a follow-up.References: https://www.anthropic.com/news/claude-opus-5-5 · https://platform.claude.com/docs/en/models/opus-5-5/migration-guide · https://platform.claude.com/docs/en/about-claude/models/overview
Tests (red/green, lint, live)
New tests kept, source reverted to
main:With the fix:
How often the block appears (raw boto3
converse, no thinking settings):Live through
BedrockChatCompletion, same scripts, only the source file differs:Tool calls on
us.anthropic.claude-opus-5-5(oneget_weather(city)function):Contribution Checklist