FunctionTool
type FunctionTool<Context, TParameters, Result> = object;
Exposes a function to the agent as a tool to be called
Type Parameters
Section titled “Type Parameters”Type Parameter | Default type | Description |
---|---|---|
|
The context of the tool |
|
|
|
‐ |
|
|
The result of the tool |
Properties
Section titled “Properties”description
Section titled “description”description: string;
The description of the tool that helps the model to understand when to use the tool
invoke()
Section titled “invoke()”invoke: (runContext, input) => Promise<string | Result>;
The function to invoke when the tool is called.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
|
|
|
|
Returns
Section titled “Returns”Promise
<string
| Result
>
name: string;
The name of the tool.
needsApproval
Section titled “needsApproval”needsApproval: ToolApprovalFunction<TParameters>;
Whether the tool needs human approval before it can be called. If this is true, the run will result in an interruption
that the
program has to resolve by approving or rejecting the tool call.
parameters
Section titled “parameters”parameters: JsonObjectSchema<any>;
A JSON schema describing the parameters of the tool.
strict
Section titled “strict”strict: boolean;
Whether the tool is strict. If true, the model must try to strictly follow the schema (might result in slower response times).
type: "function";