fix(prompt): treat post-dispatch failures as accepted

This commit is contained in:
YeonGyu-Kim
2026-05-20 11:42:32 +09:00
parent f540249838
commit d3e218f912
31 changed files with 503 additions and 76 deletions
@@ -41,6 +41,33 @@ describe("background-agent session routing", () => {
expect(promptAsync.mock.calls[0]?.[0].query).toEqual({ directory: "/workspace/project" })
})
test("#given routed promptAsync reports ambiguous EOF after dispatch #when the background route handles it #then it treats the prompt as accepted", async () => {
// given
const promptAsync = mock(async () => {
throw new Error("JSON Parse error: Unexpected EOF")
})
const client = {
session: {
promptAsync,
},
}
const args = {
path: { id: "ses_background_route_ambiguous_eof" },
body: { parts: [{ type: "text", text: "continue" }] },
}
// when
const result = await promptAsyncInDirectory(
unsafeTestValue(client),
unsafeTestValue(args),
"/workspace/project",
)
// then
expect(result).toBeUndefined()
expect(promptAsync).toHaveBeenCalledTimes(1)
})
test("#given a background retry prompt just dispatched #when the same child session is prompted again immediately #then retry routing defers instead of enqueueing", async () => {
// given
const promptAsync = mock(async () => undefined)