ZodToolSpec
Defined in: core/src/zod.ts:43
R is what run returns. It is O unless output parses it into something else.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
I |
- |
O |
- |
R |
O |
Properties
Section titled “Properties”clampOverflow?
Section titled “clampOverflow?”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.
describeIssues?
Section titled “describeIssues?”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
error |
ZodError |
checked |
"input" | "result" |
Returns
Section titled “Returns”string
description
Section titled “description”description: string;Defined in: core/src/zod.ts:45
input: ZodType<I>;Defined in: core/src/zod.ts:46
isConcurrencySafe?
Section titled “isConcurrencySafe?”optional isConcurrencySafe?: boolean;Defined in: core/src/zod.ts:60
isReadOnly?
Section titled “isReadOnly?”optional isReadOnly?: boolean;Defined in: core/src/zod.ts:58
isTerminal?
Section titled “isTerminal?”optional isTerminal?: boolean;Defined in: core/src/zod.ts:61
name: string;Defined in: core/src/zod.ts:44
needsApproval?
Section titled “needsApproval?”optional needsApproval?: boolean;Defined in: core/src/zod.ts:59
output?
Section titled “output?”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
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
I |
ctx |
ToolContext |
Returns
Section titled “Returns”Promise<R>
summarize?
Section titled “summarize?”optional summarize?: (output) => string;Defined in: core/src/zod.ts:56
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
output |
O |
Returns
Section titled “Returns”string
timeoutMs?
Section titled “timeoutMs?”optional timeoutMs?: number;Defined in: core/src/zod.ts:57