Skip to content
providerkit
GitHub

ZodToolSpec

Defined in: core/src/zod.ts:43

R is what run returns. It is O unless output parses it into something else.

Type Parameter Default type
I -
O -
R O
optional clampOverflow?: boolean;

Defined in: core/src/zod.ts:69

Clamp overflow to the bounds the schema already advertised instead of rejecting the call. Worth it for a TERMINAL tool, which gets no second chance: a forced-submit salvage turn runs exactly once, and discarding an otherwise-valid answer over a few extra characters loses the whole run. Off by default: an ordinary tool can simply be called again.


optional describeIssues?: (error, checked) => string;

Defined in: core/src/zod.ts:86

Writes the problems zod found in your words instead of zod’s, for the input check and the output check. zod’s sentence can list every value a field accepts and quote the caller’s key names, and an app that saves tool replies keeps that text: an adopter shows each reply again in its studio for a week, so it words a problem from its path and code alone. That tells the model less. A bare invalid_type at sheets once sent a model back to resend the same call, which is why the default keeps zod’s sentence.

It gets zod’s error, with every issue, and checked: input for the model’s arguments, result for what run returned. On input it words the same parse invoke and accepts decide by, after the repairs. Only the default stops at five issues. A check that throws reads as its own message, and so does a describeIssues that throws. On both checks, the error the tool throws keeps zod’s error as its cause, or what was thrown in its place, so your logs find it at ToolOutcome.cause.cause. Defaults to zod’s message for each issue, after its path.

Parameter Type
error ZodError
checked "input" | "result"

string


description: string;

Defined in: core/src/zod.ts:45


input: ZodType<I>;

Defined in: core/src/zod.ts:46


optional isConcurrencySafe?: boolean;

Defined in: core/src/zod.ts:60


optional isReadOnly?: boolean;

Defined in: core/src/zod.ts:58


optional isTerminal?: boolean;

Defined in: core/src/zod.ts:61


name: string;

Defined in: core/src/zod.ts:44


optional needsApproval?: boolean;

Defined in: core/src/zod.ts:59


optional output?: ZodType<O, R, $ZodTypeInternals<O, R>>;

Defined in: core/src/zod.ts:54

Checks every result before the model or your code reads it, and fills outputSchema for generated result types. run returns what the schema takes, unknown included, and the tool returns what the schema parses that into, after any transform. A result that fails is a failed outcome the model reads, and its value is dropped. A result that passes is the parsed value, so unknown keys are dropped and defaults are filled in before the model sees it.


run: (input, ctx) => Promise<R>;

Defined in: core/src/zod.ts:55

Parameter Type
input I
ctx ToolContext

Promise<R>


optional summarize?: (output) => string;

Defined in: core/src/zod.ts:56

Parameter Type
output O

string


optional timeoutMs?: number;

Defined in: core/src/zod.ts:57