fix(ai): harden Bedrock unsigned thinking replay closes #2063
This commit is contained in:
@@ -537,11 +537,21 @@ function convertMessages(
|
|||||||
// For other models, we omit the signature to avoid errors like:
|
// For other models, we omit the signature to avoid errors like:
|
||||||
// "This model doesn't support the reasoningContent.reasoningText.signature field"
|
// "This model doesn't support the reasoningContent.reasoningText.signature field"
|
||||||
if (supportsThinkingSignature(model)) {
|
if (supportsThinkingSignature(model)) {
|
||||||
|
// Signatures arrive after thinking deltas. If a partial or externally
|
||||||
|
// persisted message lacks a signature, Bedrock rejects the replayed
|
||||||
|
// reasoning block. Fall back to plain text, matching Anthropic.
|
||||||
|
if (!c.thinkingSignature || c.thinkingSignature.trim().length === 0) {
|
||||||
|
contentBlocks.push({ text: sanitizeSurrogates(c.thinking) });
|
||||||
|
} else {
|
||||||
contentBlocks.push({
|
contentBlocks.push({
|
||||||
reasoningContent: {
|
reasoningContent: {
|
||||||
reasoningText: { text: sanitizeSurrogates(c.thinking), signature: c.thinkingSignature },
|
reasoningText: {
|
||||||
|
text: sanitizeSurrogates(c.thinking),
|
||||||
|
signature: c.thinkingSignature,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
contentBlocks.push({
|
contentBlocks.push({
|
||||||
reasoningContent: {
|
reasoningContent: {
|
||||||
|
|||||||
Reference in New Issue
Block a user