馃┕ fix: Don't Replay Reasoning to OpenAI Bedrock Models - #581
Merged
danny-avila merged 4 commits intoSep 30, 2026
Merged
danny-avila merged 4 commits into
danny-avila merged 4 commits into
Conversation
A handoff that stays on Bedrock but changes model family (an agent on Claude handing over to one on OpenAI GPT) fails on the receiving agent's first request. The Claude turns in the history keep Bedrock-native reasoning_content, and the cross-provider reasoning drop only covers reasoning from another provider, so the blocks reach the GPT request and Bedrock rejects it: ValidationException: This model doesn't support the reasoningContent.reasoningText.text field for assistant messages. The same happens when a conversation switches from Claude to GPT. convertToConverseMessages now takes the target model, and the Bedrock chat model passes this.model. Prior reasoning (reasoning_content, and v1 reasoning blocks) is replayed only to Claude; for any other identified model it is dropped, and a turn left empty gets the existing placeholder. A model that can't be identified (none given, or an ARN) keeps the reasoning, so existing callers are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 task done
Contributor
|
Updated this PR to
CI for this exact head is awaiting GitHub's fork-workflow approval. No external review has arrived for this head yet. Live Bedrock API validation and the full local repository test suite were not run. The non-streaming path remains outside this PR's scope. |
Contributor
|
Independent review follow-up pushed to
CI state: in_progress. No external review has arrived for this head yet. CI on the prior ARN-only head Live Bedrock validation and the full local repository test suite were not run. No issue labels, issue comments, release, or dependency-bump changes were made. |
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.
Summary
A handoff from Bedrock Claude to Bedrock OpenAI GPT fails on the receiving agent's first request once the history includes Claude reasoning. Bedrock rejects the request with:
In LibreChat this occurs during a handoff within one run. Reported in LibreChat-AI/LibreChat#16510. The reported production case was a Claude Sonnet 5 agent handing off to
global.openai.gpt-6-lunaafter tool use.Cause
Claude turns keep Bedrock-native
reasoning_contentwith their reasoning text and signature. The existing cross-provider filter removes reasoning from other providers, but both agents here use Bedrock. The converter therefore sends Claude's reasoning back asreasoningContentto an OpenAI target that rejects it.Change
convertToConverseMessages(messages, { model })takes the target model. The streaming adapter passesthis.model, keeping the base model identity separate from an optional application inference profile.reasoning_contentand v1reasoningblocks for identifiedopenai.*targets, including geography-prefixed model IDs. Keep text and tool calls. A reasoning-only assistant turn uses the existing_placeholder.foundation-model/and systeminference-profile/ARNs. OpenAI targets do not bypass the filter just because they are configured by ARN.Out of scope:
_generateNonStreamingstill delegates to@langchain/aws's converter. This PR does not validate every model family's Bedrock reasoning-replay requirements or change their behavior.Tests
Conversion and outgoing streaming request regressions cover:
The original ARN regressions produced 8 expected failures before the ARN fix. The compatibility regressions produced 18 expected failures under the broader Claude-only rule.
Final local checks and exact-head CI state are recorded in the latest head handoff comment. Live Bedrock API validation and the full local repository test suite were not run.
馃 Generated with Claude Code; review follow-ups by Lia.