Skip to content

Commit 5dd0f62

Browse files
MarcoDotIOclaude
andcommitted
fix(acp): cancelled ACP tool calls no longer stay running and end as completed
ACP v2 reports `cancelled` as a terminal tool call status, but the status normalizer only knew pending, in_progress, completed and failed. A cancelled update kept the previous in-progress status, so the tool showed as running and was then closed as completed when the turn ended. Treat it like the failed outcome, matching how compaction_update already maps cancelled. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 210b2e7 commit 5dd0f62

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
@@ -295,6 +295,38 @@ describe("AcpRuntimeModel", () => {
295295
}
296296
});
297297

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

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ function normalizeToolCallStatus(
515515
case "completed":
516516
return "completed";
517517
case "failed":
518+
case "cancelled":
518519
return "failed";
519520
default:
520521
return fallback;

0 commit comments

Comments
 (0)