Skip to content

Commit 29ec077

Browse files
authored
fix: bedrock reasoning issue (#25303)
1 parent bcae852 commit 29ec077

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

packages/opencode/src/session/message-v2.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,10 +938,18 @@ export const toModelMessagesEffect = Effect.fnUntraced(function* (
938938
})
939939
}
940940
if (part.type === "reasoning") {
941+
if (differentModel) {
942+
if (part.text.trim().length > 0)
943+
assistantMessage.parts.push({
944+
type: "text",
945+
text: part.text,
946+
})
947+
continue
948+
}
941949
assistantMessage.parts.push({
942950
type: "reasoning",
943951
text: part.text,
944-
...(differentModel ? {} : { providerMetadata: part.metadata }),
952+
providerMetadata: part.metadata,
945953
})
946954
}
947955
}

packages/opencode/test/session/message-v2.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,13 @@ describe("session.message-v2.toModelMessage", () => {
469469
},
470470
{
471471
...basePart(assistantID, "a2"),
472+
type: "reasoning",
473+
text: "thinking",
474+
metadata: { openai: { reasoning: "meta" } },
475+
time: { start: 0 },
476+
},
477+
{
478+
...basePart(assistantID, "a3"),
472479
type: "tool",
473480
callID: "call-1",
474481
tool: "bash",
@@ -495,6 +502,7 @@ describe("session.message-v2.toModelMessage", () => {
495502
role: "assistant",
496503
content: [
497504
{ type: "text", text: "done" },
505+
{ type: "text", text: "thinking" },
498506
{
499507
type: "tool-call",
500508
toolCallId: "call-1",

0 commit comments

Comments
 (0)