Skip to content

Commit 9d8eb86

Browse files
committed
fix(fx): classify first cancelled tool updates as interrupted
1 parent 1dae9ac commit 9d8eb86

3 files changed

Lines changed: 25 additions & 2 deletions

File tree

‎apps/server/scripts/acp-mock-agent.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,17 @@ const program = Effect.gen(function* () {
13201320
content: [{ type: "content", content: { type: "text", text: "Cancelled." } }],
13211321
},
13221322
});
1323+
yield* agent.client.sessionUpdate({
1324+
sessionId: requestedSessionId,
1325+
update: {
1326+
sessionUpdate: "tool_call_update",
1327+
toolCallId: "native-unseen-cancel-tool",
1328+
title: "Cancelled command",
1329+
kind: "execute",
1330+
status: "failed",
1331+
content: [{ type: "content", content: { type: "text", text: "Cancelled." } }],
1332+
},
1333+
});
13231334
// A later output-only update must not undo the interrupted status.
13241335
yield* agent.client.sessionUpdate({
13251336
sessionId: requestedSessionId,

‎apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5439,7 +5439,9 @@ describe("AcpAdapterV2", () => {
54395439
: undefined,
54405440
isCancelledToolCall: Schema.is(
54415441
Schema.Struct({
5442-
update: Schema.Struct({ toolCallId: Schema.Literal("native-cancel-tool") }),
5442+
update: Schema.Struct({
5443+
toolCallId: Schema.Literals(["native-cancel-tool", "native-unseen-cancel-tool"]),
5444+
}),
54435445
}),
54445446
),
54455447
makeRuntime: makeMockRuntime({
@@ -5531,6 +5533,15 @@ describe("AcpAdapterV2", () => {
55315533
: [],
55325534
)
55335535
.at(-1);
5536+
const unseenCommand = untilTerminal
5537+
.flatMap((event) =>
5538+
event.type === "turn_item.updated" &&
5539+
event.turnItem.nativeItemRef?.nativeId === "native-unseen-cancel-tool"
5540+
? [event.turnItem]
5541+
: [],
5542+
)
5543+
.at(-1);
5544+
assert.equal(unseenCommand?.status, "interrupted");
55345545
assert.equal(command?.status, "interrupted");
55355546
assert.include(command?.type === "command_execution" ? command.output : "", "exit 130");
55365547
const failure = untilTerminal

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3765,7 +3765,8 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
37653765
context.interrupted &&
37663766
toolCall.status === "failed" &&
37673767
flavor.isCancelledToolCall?.(rawPayload) === true &&
3768-
(previousStatus === "pending" ||
3768+
(previousStatus === undefined ||
3769+
previousStatus === "pending" ||
37693770
previousStatus === "running" ||
37703771
previousStatus === "waiting")
37713772
) {

0 commit comments

Comments
 (0)