mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-26 02:05:31 +00:00
fix(acp): reject replacement prompt if session retires during interrupt and preserve streaming reply id
This commit is contained in:
@@ -657,6 +657,9 @@ class AcpRuntime {
|
||||
await this.interrupt();
|
||||
}
|
||||
await active.settled;
|
||||
if (this.closing || this.processFailed) {
|
||||
throw new Error("ACP session is closed");
|
||||
}
|
||||
}
|
||||
const prompt = toAcpPrompt(input.prompt);
|
||||
this.replayWindow = null;
|
||||
@@ -1601,7 +1604,7 @@ class AcpRuntime {
|
||||
this.finishDeferredTurn(active, { type: "cancel" });
|
||||
return;
|
||||
}
|
||||
this.fallbackChunkIds.clear();
|
||||
if (this.hasQualifyingOpenTools()) this.fallbackChunkIds.clear();
|
||||
if (response.stopReason !== "end_turn" && active.wirePromptsInFlight === 1) {
|
||||
this.finishDeferredTurn(active, { type: "complete", terminalizeTools: true });
|
||||
}
|
||||
|
||||
@@ -3726,7 +3726,7 @@ describe("deferTurnOnRunningTools", () => {
|
||||
type: "timeline.item",
|
||||
item: expect.objectContaining({
|
||||
type: "assistant_message",
|
||||
text: expect.stringContaining("part 2."),
|
||||
text: "Background reply part 1 part 2.",
|
||||
}),
|
||||
}),
|
||||
);
|
||||
@@ -4507,9 +4507,13 @@ describe("deferTurnOnRunningTools", () => {
|
||||
);
|
||||
|
||||
await connection.send({
|
||||
type: "session.interrupt",
|
||||
requestId: "wedged-stop",
|
||||
type: "session.prompt",
|
||||
sessionId: "session-1",
|
||||
prompt: {
|
||||
clientMessageId: "wedged-replacement",
|
||||
delivery: "auto",
|
||||
input: { type: "message", content: [{ type: "text", text: "replace wedged turn" }] },
|
||||
},
|
||||
});
|
||||
await waitForEvent(
|
||||
events,
|
||||
@@ -4519,6 +4523,18 @@ describe("deferTurnOnRunningTools", () => {
|
||||
event.state === "canceled",
|
||||
);
|
||||
await waitForEvent(events, (event) => event.type === "session.runtime_failed");
|
||||
await waitForEvent(
|
||||
events,
|
||||
(event) =>
|
||||
event.type === "session.prompt_result" &&
|
||||
event.clientMessageId === "wedged-replacement" &&
|
||||
event.result.type === "failed",
|
||||
);
|
||||
expect(
|
||||
events.some(
|
||||
(event) => event.type === "session.turn" && event.turnId === "acp:wedged-replacement",
|
||||
),
|
||||
).toBe(false);
|
||||
|
||||
// The wedged child process must actually be terminated.
|
||||
await expect
|
||||
|
||||
Reference in New Issue
Block a user