Просмотр исходного кода

tweak: make zod error more prompty

Aiden Cline 3 месяцев назад
Родитель
Сommit
edc933d816
1 измененных файлов с 5 добавлено и 2 удалено
  1. 5 2
      packages/opencode/src/tool/tool.ts

+ 5 - 2
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)
         }