Skip to content

Commit 579de19

Browse files
committed
fix(fx): recognize cancellation errors from fx 0.0.16
1 parent 336badc commit 579de19

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

‎packages/provider-fx/src/server/acpSupport.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ describe("fx cancellation failures", () => {
4040
{ content: ["Cancelled"], cancelled: true },
4141
{ content: ["Cancelled."], cancelled: true },
4242
{ content: ['{"error":{"details":{"error":"Cancelled"}}}'], cancelled: true },
43+
{
44+
content: ['{"error":{"tool":"shell","code":"Cancelled","retryable":false}}'],
45+
cancelled: true,
46+
},
47+
{
48+
content: ['{"error":{"tool":"shell","code":"PermissionDenied","retryable":false}}'],
49+
cancelled: false,
50+
},
4351
{ content: ['{"error":{"details":{"error":"Permission denied"}}}'], cancelled: false },
4452
{ content: ["Command failed"], cancelled: false },
4553
{ content: [""], cancelled: false },

‎packages/provider-fx/src/server/acpSupport.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ const decodeFxContentText = Schema.decodeUnknownOption(
8282
const decodeFxCancelledError = Schema.decodeUnknownOption(
8383
Schema.fromJsonString(
8484
Schema.Struct({
85-
error: Schema.Struct({ details: Schema.Struct({ error: Schema.Literal("Cancelled") }) }),
85+
error: Schema.Union([
86+
Schema.Struct({ details: Schema.Struct({ error: Schema.Literal("Cancelled") }) }),
87+
Schema.Struct({ code: Schema.Literal("Cancelled") }),
88+
]),
8689
}),
8790
),
8891
);

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ const decodeFxToolError = Schema.decodeUnknownOption(
102102
Schema.fromJsonString(
103103
Schema.Struct({
104104
error: Schema.Struct({
105-
message: Schema.String,
105+
message: Schema.optional(Schema.String),
106+
code: Schema.optional(Schema.String),
106107
details: Schema.optional(Schema.Struct({ error: Schema.optional(Schema.String) })),
107108
}),
108109
}),
@@ -158,7 +159,12 @@ function extractFxSubagentUpdate(tool: AcpToolCallState): AcpAdapterV2SubagentUp
158159
result:
159160
status === "running"
160161
? null
161-
: (outcome?.result ?? failure?.details?.error ?? failure?.message ?? text ?? null),
162+
: (outcome?.result ??
163+
failure?.details?.error ??
164+
failure?.message ??
165+
failure?.code ??
166+
text ??
167+
null),
162168
};
163169
}
164170

0 commit comments

Comments
 (0)