Skip to content

Commit 076aacc

Browse files
MarcoDotIOclaude
andauthored
fix(acp): cancelled ACP tool calls no longer stay running and end as completed (#25559)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 286bc5e commit 076aacc

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

‎packages/provider-acp/src/server/runtimeModel.test.ts‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,38 @@ describe("AcpRuntimeModel", () => {
296296
}
297297
});
298298

299+
it("ends a tool call that ACP reports as cancelled", () => {
300+
const toolCall = (status: EffectAcpSchema.ToolCallStatus) => {
301+
const parsed = parseSessionUpdateEvent({
302+
sessionId: "session-1",
303+
update: {
304+
sessionUpdate: status === "in_progress" ? "tool_call" : "tool_call_update",
305+
toolCallId: "tool-1",
306+
title: "Run `sleep 60`",
307+
kind: "execute",
308+
status,
309+
},
310+
} as EffectAcpSchema.SessionNotification);
311+
const event = parsed.events[0];
312+
if (event?._tag !== "ToolCallUpdated") {
313+
throw new Error("expected a tool call update");
314+
}
315+
return event.toolCall;
316+
};
317+
318+
const running = toolCall("in_progress");
319+
const cancelled = mergeToolCallState(running, toolCall("cancelled"));
320+
expect(cancelled.status).toBe("failed");
321+
expect(
322+
decideToolCallUpdateEmission({
323+
previous: running,
324+
next: cancelled,
325+
lastEmittedDetailLength: 0,
326+
skippedSinceEmit: 0,
327+
}).emit,
328+
).toBe(true);
329+
});
330+
299331
it("clears prior ACP locations when an update explicitly replaces them", () => {
300332
const toolCall = (locations?: EffectAcpSchema.ToolCallLocation[] | null) => {
301333
const parsed = parseSessionUpdateEvent({

‎packages/provider-acp/src/server/runtimeModel.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ function normalizeToolCallStatus(
522522
case "completed":
523523
return "completed";
524524
case "failed":
525+
case "cancelled":
525526
return "failed";
526527
default:
527528
return fallback;

0 commit comments

Comments
 (0)