From 8947866732c5d74c3ee449671e8ddccf997de152 Mon Sep 17 00:00:00 2001 From: Rhys Sullivan <39114868+RhysSullivan@users.noreply.github.com> Date: Tue, 2 Jun 2026 10:46:56 -0700 Subject: [PATCH] refactor(errors): make ToolInvocationError schema-backed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Convert `ToolInvocationError` from `Data.TaggedError` to `Schema.TaggedErrorClass` (`cause` -> `Schema.optional(Schema.Defect)`). It was the only non-schema member of the `ExecutorError` union, so the whole union — which is returned across the SDK/MCP wire — is now fully schema-encodable. The remaining `Data.TaggedError` errors are internal or mapped to `ToolResult` before the wire (the module-private exception), so they stay as-is. Verified: typecheck (all 38 packages), lint (0/0), format, sdk tests. --- packages/core/sdk/src/errors.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/core/sdk/src/errors.ts b/packages/core/sdk/src/errors.ts index 59efd95a5..764e0f2eb 100644 --- a/packages/core/sdk/src/errors.ts +++ b/packages/core/sdk/src/errors.ts @@ -1,4 +1,4 @@ -import { Data, Schema } from "effect"; +import { Schema } from "effect"; import { ConnectionId, ToolId, SecretId } from "./ids"; @@ -14,11 +14,14 @@ export class ToolNotFoundError extends Schema.TaggedErrorClass {} +export class ToolInvocationError extends Schema.TaggedErrorClass()( + "ToolInvocationError", + { + toolId: ToolId, + message: Schema.String, + cause: Schema.optional(Schema.Defect), + }, +) {} /** Tool row exists in the DB but its owning plugin isn't loaded. Means * the tool was registered by a plugin that's no longer present in the