Skip to content

Commit f54a21b

Browse files
author
kostiantyn-kugot
committed
fix: blank assistant text with MCP enabled after AI SDK v6 migration
The v6 upgrade changed the default unmapped finish reason from "unknown" to "other", but the prompt loop continue sets were not updated to match. This caused premature loop exit after MCP tool calls, before the model produced final assistant text. Fixes #20050 Fixes #20465
1 parent 825ab2e commit f54a21b

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

packages/opencode/src/cli/cmd/tui/routes/session/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1359,7 +1359,7 @@ function AssistantMessage(props: { message: AssistantMessage; parts: Part[]; las
13591359
const model = createMemo(() => Model.name(ctx.providers(), props.message.providerID, props.message.modelID))
13601360

13611361
const final = createMemo(() => {
1362-
return props.message.finish && !["tool-calls", "unknown"].includes(props.message.finish)
1362+
return props.message.finish && !["tool-calls", "other"].includes(props.message.finish)
13631363
})
13641364

13651365
const duration = createMemo(() => {

packages/opencode/src/session/prompt.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,7 @@ NOTE: At any point in time through this workflow you should feel free to ask the
14381438

14391439
if (
14401440
lastAssistant?.finish &&
1441-
!["tool-calls"].includes(lastAssistant.finish) &&
1441+
!["tool-calls", "other"].includes(lastAssistant.finish) &&
14421442
!hasToolCalls &&
14431443
lastUser.id < lastAssistant.id
14441444
) {
@@ -1593,7 +1593,7 @@ NOTE: At any point in time through this workflow you should feel free to ask the
15931593
return "break" as const
15941594
}
15951595

1596-
const finished = handle.message.finish && !["tool-calls", "unknown"].includes(handle.message.finish)
1596+
const finished = handle.message.finish && !["tool-calls", "other"].includes(handle.message.finish)
15971597
if (finished && !handle.message.error) {
15981598
if (format.type === "json_schema") {
15991599
handle.message.error = new MessageV2.StructuredOutputError({

0 commit comments

Comments
 (0)