From edc933d816e19acd4dd504cc51fddefadd5f9276 Mon Sep 17 00:00:00 2001 From: Aiden Cline Date: Sat, 15 Nov 2025 13:19:24 -0600 Subject: [PATCH] tweak: make zod error more prompty --- packages/opencode/src/tool/tool.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/opencode/src/tool/tool.ts b/packages/opencode/src/tool/tool.ts index 91515195..80b6abe8 100644 --- a/packages/opencode/src/tool/tool.ts +++ b/packages/opencode/src/tool/tool.ts @@ -50,9 +50,12 @@ export namespace Tool { toolInfo.parameters.parse(args) } catch (error) { if (error instanceof z.ZodError && toolInfo.formatValidationError) { - throw new Error(toolInfo.formatValidationError(error)) + throw new Error(toolInfo.formatValidationError(error), { cause: error }) } - throw error + throw new Error( + `The ${id} tool was called with invalid arguments: ${error}.\nPlease rewrite the input so it satisfies the expected schema.`, + { cause: error }, + ) } return execute(args, ctx) }