fix: bedrock reasoning issue (#25303)
This commit is contained in:
@@ -938,10 +938,18 @@ export const toModelMessagesEffect = Effect.fnUntraced(function* (
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (part.type === "reasoning") {
|
if (part.type === "reasoning") {
|
||||||
|
if (differentModel) {
|
||||||
|
if (part.text.trim().length > 0)
|
||||||
|
assistantMessage.parts.push({
|
||||||
|
type: "text",
|
||||||
|
text: part.text,
|
||||||
|
})
|
||||||
|
continue
|
||||||
|
}
|
||||||
assistantMessage.parts.push({
|
assistantMessage.parts.push({
|
||||||
type: "reasoning",
|
type: "reasoning",
|
||||||
text: part.text,
|
text: part.text,
|
||||||
...(differentModel ? {} : { providerMetadata: part.metadata }),
|
providerMetadata: part.metadata,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -469,6 +469,13 @@ describe("session.message-v2.toModelMessage", () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
...basePart(assistantID, "a2"),
|
...basePart(assistantID, "a2"),
|
||||||
|
type: "reasoning",
|
||||||
|
text: "thinking",
|
||||||
|
metadata: { openai: { reasoning: "meta" } },
|
||||||
|
time: { start: 0 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
...basePart(assistantID, "a3"),
|
||||||
type: "tool",
|
type: "tool",
|
||||||
callID: "call-1",
|
callID: "call-1",
|
||||||
tool: "bash",
|
tool: "bash",
|
||||||
@@ -495,6 +502,7 @@ describe("session.message-v2.toModelMessage", () => {
|
|||||||
role: "assistant",
|
role: "assistant",
|
||||||
content: [
|
content: [
|
||||||
{ type: "text", text: "done" },
|
{ type: "text", text: "done" },
|
||||||
|
{ type: "text", text: "thinking" },
|
||||||
{
|
{
|
||||||
type: "tool-call",
|
type: "tool-call",
|
||||||
toolCallId: "call-1",
|
toolCallId: "call-1",
|
||||||
|
|||||||
Reference in New Issue
Block a user