fix: tweaks to transform logic for anthropic and bedrock (#26276)

This commit is contained in:
Aiden Cline
2026-05-07 23:17:43 -05:00
committed by GitHub
parent e0396b809a
commit 4e14f79511
3 changed files with 190 additions and 24 deletions

View File

@@ -135,9 +135,16 @@ function normalizeMessages(
}
if (!Array.isArray(msg.content)) return msg
const filtered = msg.content.filter((part) => {
if (part.type === "text" || part.type === "reasoning") {
if (part.type === "text") {
return part.text !== ""
}
if (part.type === "reasoning") {
return (
part.text.trim().length > 0 ||
part.providerOptions?.anthropic?.signature != null ||
part.providerOptions?.anthropic?.redactedData != null
)
}
return true
})
if (filtered.length === 0) return undefined
@@ -156,9 +163,16 @@ function normalizeMessages(
}
if (!Array.isArray(msg.content)) return msg
const filtered = msg.content.filter((part) => {
if (part.type === "text" || part.type === "reasoning") {
if (part.type === "text") {
return part.text !== ""
}
if (part.type === "reasoning") {
return (
part.text.trim().length > 0 ||
part.providerOptions?.bedrock?.signature != null ||
part.providerOptions?.bedrock?.redactedData != null
)
}
return true
})
if (filtered.length === 0) return undefined