API Reference
validateToolArguments
function validateToolArguments(tool, call): ToolArguments;Defined in: tools/tools.ts:137
Validate a tool call against the tool's schema, returning the parsed arguments.
Parameters
| Parameter | Type | Description |
|---|---|---|
tool | Tool | The tool whose schema the call is checked against. |
call | ToolCall | The model-emitted tool call, whose function.arguments is a JSON string. |
Returns
The parsed, schema-valid arguments as an object.
Remarks
The throwing counterpart of tryValidateToolArguments: it delegates the
parse-and-check there and throws the reported error on failure. The loop
converts that thrown error into an error tool-result rather than crashing the
run.
Throws
Error if the arguments are not valid JSON.
Throws
Error if the parsed arguments fail the tool's Zod schema (the message lists the failing paths).
See
tryValidateToolArguments for the non-throwing variant.