cli: fix question recovery matching wrong session

The recovery logic matched questions by checking if the list was
non-empty, which caused it to pick up stale questions from earlier
turns. When a re-ask fired, the wrong question could resolve the
blocker, leaving the real question undelivered and the process stuck.

Match questions by messageID and callID from the originating tool part
so only the correct question unblocks the prompt.

Fixes #27503
This commit is contained in:
Simon Klee
2026-05-14 21:54:28 +02:00
parent 418c0ea04a
commit f2f8efa411
2 changed files with 24 additions and 13 deletions
@@ -835,12 +835,17 @@ describe("run stream transport", () => {
callID: "call-question-1",
},
}
const stale = {
...request,
id: "question-old",
tool: { messageID: "msg-old", callID: "call-question-old" },
}
const transport = await createSessionTransport({
sdk: sdk({
stream: src.stream,
questions: async () => {
questionCalls += 1
return ok(questionCalls > 1 ? [request] : [])
return ok(questionCalls === 1 ? [stale] : [stale, request])
},
promptAsync: async () => {
queueMicrotask(() => {
@@ -885,7 +890,9 @@ describe("run stream transport", () => {
const view = await waitFor(() => {
const item = ui.events.findLast((event) => event.type === "stream.view")
return item?.type === "stream.view" && item.view.type === "question" ? item.view : undefined
return item?.type === "stream.view" && item.view.type === "question" && item.view.request.id === request.id
? item.view
: undefined
})
expect(view).toEqual({