Skip to content

FunctionTool

type FunctionTool<Context, TParameters, Result> = object;

Exposes a function to the agent as a tool to be called

Type Parameter Default type Description

Context

UnknownContext

The context of the tool

TParameters extends ToolInputParameters

undefined

Result

unknown

The result of the tool

description: string;

The description of the tool that helps the model to understand when to use the tool


invoke: (runContext, input) => Promise<string | Result>;

The function to invoke when the tool is called.

Parameter Type

runContext

RunContext<Context>

input

string

Promise<string | Result>


name: string;

The name of the tool.


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: JsonObjectSchema<any>;

A JSON schema describing the parameters of the tool.


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";