From 4396ac9dd6307bb7d7870a8415f590cfecae16b7 Mon Sep 17 00:00:00 2001 From: Shardul Vaidya <31039336+5herlocked@users.noreply.github.com> Date: Wed, 25 Jun 2025 07:51:25 -0400 Subject: [PATCH] bedrock: DeepSeek does not support receiving Reasoning Blocks (#33326) Closes #32341 Release Notes: - Fixed DeepSeek R1 errors for reasoning blocks being sent back to the model. --- crates/language_models/src/provider/bedrock.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/language_models/src/provider/bedrock.rs b/crates/language_models/src/provider/bedrock.rs index e305569ce2..2b2527f1ac 100644 --- a/crates/language_models/src/provider/bedrock.rs +++ b/crates/language_models/src/provider/bedrock.rs @@ -631,6 +631,11 @@ pub fn into_bedrock( } } MessageContent::Thinking { text, signature } => { + if model.contains(Model::DeepSeekR1.request_id()) { + // DeepSeekR1 doesn't support thinking blocks + // And the AWS API demands that you strip them + return None; + } let thinking = BedrockThinkingTextBlock::builder() .text(text) .set_signature(signature) @@ -643,6 +648,11 @@ pub fn into_bedrock( )) } MessageContent::RedactedThinking(blob) => { + if model.contains(Model::DeepSeekR1.request_id()) { + // DeepSeekR1 doesn't support thinking blocks + // And the AWS API demands that you strip them + return None; + } let redacted = BedrockThinkingBlock::RedactedContent(BedrockBlob::new(blob));