Skip to content

Commit 57fa34f

Browse files
fix(opencode): continue unknown finish responses (anomalyco#43892)
Co-authored-by: rekram1-node <[email protected]>
1 parent 0af9dd6 commit 57fa34f

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

‎packages/opencode/src/session/prompt.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ const layer = Layer.effect(
11101110

11111111
if (
11121112
lastAssistant?.finish &&
1113-
!["tool-calls"].includes(lastAssistant.finish) &&
1113+
!["tool-calls", "unknown"].includes(lastAssistant.finish) &&
11141114
!hasToolCalls &&
11151115
lastAssistant.parentID === lastUser.id
11161116
) {

‎packages/opencode/test/session/prompt.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,34 @@ it.instance("loop continues when finish is tool-calls", () =>
850850
}),
851851
)
852852

853+
it.instance("loop continues when finish is unknown", () =>
854+
Effect.gen(function* () {
855+
const { llm } = yield* useServerConfig(providerCfg)
856+
const prompt = yield* SessionPrompt.Service
857+
const sessions = yield* Session.Service
858+
const session = yield* sessions.create({
859+
title: "Pinned",
860+
permission: [{ permission: "*", pattern: "*", action: "allow" }],
861+
})
862+
yield* prompt.prompt({
863+
sessionID: session.id,
864+
agent: "build",
865+
noReply: true,
866+
parts: [{ type: "text", text: "hello" }],
867+
})
868+
yield* llm.push(reply())
869+
yield* llm.text("second")
870+
871+
const result = yield* prompt.loop({ sessionID: session.id })
872+
expect(yield* llm.calls).toBe(2)
873+
expect(result.info.role).toBe("assistant")
874+
if (result.info.role === "assistant") {
875+
expect(result.parts.some((part) => part.type === "text" && part.text === "second")).toBe(true)
876+
expect(result.info.finish).toBe("stop")
877+
}
878+
}),
879+
)
880+
853881
it.instance("glob tool keeps instance context during prompt runs", () =>
854882
Effect.gen(function* () {
855883
const { dir, llm } = yield* useServerConfig(providerCfg)

0 commit comments

Comments
 (0)