Validation & Errors
Automatic parameter validation and error handling strategies for tools.
Parameter Validation
The tool() function automatically uses the Zod Schema to validate model-generated parameters. If parameters don't conform to the schema, the validation error is caught and returned to the model as a failure result, rather than throwing an exception that interrupts the flow:
If the model generates limit: -1, Zod validation will fail, and the model will receive an error message like "Invalid arguments: limit: Number must be greater than or equal to 1", giving it the opportunity to correct the parameters and retry.
Error Handling
Errors during tool execution are automatically caught and returned to the model. You can handle errors yourself in the execute function, or let deepseek-kit's default mechanism take over:
Even if your execute function throws an uncaught exception, deepseek-kit will catch it and convert it to a { success: false, error: "..." } format result returned to the model, ensuring the flow is never interrupted.

