Skip to content

Commit f1de956

Browse files
committed
fix: use core-appropriate error messages in runHandler instead of extension wording
runHandler is used exclusively for core agent/client RPC methods (e.g. session/prompt, fs/read_text_file), not extension methods. It was incorrectly using fromHandlerError which always emits 'ACP extension request handler failed' and tags operation as 'handle-extension-request'. Now runHandler produces 'ACP request handler failed for method ...' with operation 'handle-request', making core protocol failures distinguishable from extension failures for debugging and client-side error handling.
1 parent e545938 commit f1de956

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

packages/effect-acp/src/_internal/shared.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,17 @@ export const runHandler = Effect.fnUntraced(function* <A, B>(
3535
return yield* Effect.fail(AcpError.AcpRequestError.methodNotFound(method).toProtocolError());
3636
}
3737
return yield* handler(payload).pipe(
38-
Effect.mapError((error) =>
39-
AcpError.AcpRequestError.fromHandlerError(error, method).toProtocolError(),
40-
),
38+
Effect.mapError((error) => {
39+
const requestError =
40+
error._tag === "AcpRequestError"
41+
? error
42+
: AcpError.AcpRequestError.internalError(
43+
`ACP request handler failed for method '${method}'`,
44+
undefined,
45+
{ method, operation: "handle-request", cause: error },
46+
);
47+
return requestError.toProtocolError();
48+
}),
4149
);
4250
});
4351

packages/effect-acp/src/errors.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ describe("effect-acp errors", () => {
9696

9797
expect(error).toMatchObject({
9898
code: -32603,
99-
message: "ACP extension request handler failed for method 'fs/read_text_file'",
99+
message: "ACP request handler failed for method 'fs/read_text_file'",
100100
});
101101
expect(error.message).not.toContain(cause.message);
102102
});

packages/effect-acp/src/errors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as AcpSchema from "./_generated/schema.gen.ts";
66
export const AcpRequestOperation = Schema.Literals([
77
"decode-extension-request-payload",
88
"handle-extension-request",
9+
"handle-request",
910
]);
1011
export type AcpRequestOperation = typeof AcpRequestOperation.Type;
1112

0 commit comments

Comments
 (0)