Tool
Defined in: tools/tools.types.ts:88
A tool the agent loop can call: name, description, argument schema, and handler.
Remarks
Author tools through defineTool so the args parameter of execute
is inferred from parameters rather than the default z.ZodType.
See
Type Parameters
| Type Parameter | Default type | Description |
|---|---|---|
S extends z.ZodType | z.ZodType | The Zod schema type for the tool's arguments. |
Methods
execute()
execute(args, ctx):
| ToolResult
| Promise<ToolResult>;Defined in: tools/tools.types.ts:108
Run the tool against validated args, returning its result.
Parameters
| Parameter | Type |
|---|---|
args | output<S> |
ctx | ToolContext |
Returns
| ToolResult
| Promise<ToolResult>
Remarks
Throw to signal an error: the loop turns a thrown Error into a tool result
with isError: true and error.message as the content the model sees. Any
Error works — there is no special error type, and only the message is
surfaced (so make it descriptive). Return a ToolResult for success,
or for a soft outcome the model should simply read.
Throws
Surfaced to the model as an isError tool result, not propagated out
of the run — the loop never lets one tool's throw reject the whole run.
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
description | string | Human/model-readable description of what the tool does. | tools/tools.types.ts:92 |
executionMode? | ExecutionMode | See ExecutionMode. Defaults to Parallel. | tools/tools.types.ts:110 |
name | string | Unique tool name advertised to the model. | tools/tools.types.ts:90 |
parameters | S | Zod schema for the tool's arguments; also converted to JSON Schema for the model. | tools/tools.types.ts:94 |