Skip to content

Commit 03c4e62

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 f033d2d commit 03c4e62

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
@@ -1356,7 +1356,7 @@ function AssistantMessage(props: { message: AssistantMessage; parts: Part[]; las
13561356
const model = createMemo(() => Model.name(ctx.providers(), props.message.providerID, props.message.modelID))
13571357

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

13621362
const duration = createMemo(() => {

packages/opencode/src/session/prompt.ts

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

13481348
if (
13491349
lastAssistant?.finish &&
1350-
!["tool-calls"].includes(lastAssistant.finish) &&
1350+
!["tool-calls", "other"].includes(lastAssistant.finish) &&
13511351
!hasToolCalls &&
13521352
lastUser.id < lastAssistant.id
13531353
) {
@@ -1502,7 +1502,7 @@ NOTE: At any point in time through this workflow you should feel free to ask the
15021502
return "break" as const
15031503
}
15041504

1505-
const finished = handle.message.finish && !["tool-calls", "unknown"].includes(handle.message.finish)
1505+
const finished = handle.message.finish && !["tool-calls", "other"].includes(handle.message.finish)
15061506
if (finished && !handle.message.error) {
15071507
if (format.type === "json_schema") {
15081508
handle.message.error = new MessageV2.StructuredOutputError({

0 commit comments

Comments
 (0)