@sagentic-ai/sagentic-af / FunctionTool
FunctionTool<Args, Returns> ​
Tool is a spicy function that can describe itself with OpenAI compatible JSON schema.
Param ​
Name of the tool
Param ​
Description of the tool
Param ​
Zod schema for parameters of the tool
Param ​
Zod schema for return value of the tool
Type parameters ​
• Args
• Returns
Implements ​
Constructors ​
new FunctionTool(name, description, args, returns, func) ​
new FunctionTool<Args, Returns>(
name,
description,
args,
returns,
func): FunctionTool<Args, Returns>
Parameters ​
• name: string
• description: string
• args: ZodType
<Args
, ZodTypeDef
, Args
>
• returns: ZodType
<Returns
, ZodTypeDef
, Returns
>
• func
Returns ​
FunctionTool
<Args
, Returns
>
Source ​
Properties ​
args ​
args: ZodType<Args, ZodTypeDef, Args>;
Zod schema for parameters of the tool
Source ​
description ​
description: string;
Description of the tool
Implementation of ​
Source ​
func ​
func: (agent, args) => Promise<Returns>;
Function for the tool to perform when called
Parameters ​
• agent: Agent
• args: Args
Returns ​
Promise
<Returns
>
Source ​
name ​
name: string;
Name of the tool
Implementation of ​
Source ​
returns ​
returns: ZodType<Returns, ZodTypeDef, Returns>;
Zod schema for return value of the tool
Source ​
Methods ​
describe() ​
describe(): ChatCompletionTool
Convert a tool to OpenAI compatible tool schema.
Returns ​
ChatCompletionTool
OpenAI compatible JSON schema as JS object
Implementation of ​
Source ​
invoke() ​
invoke(agent, args): Promise<Returns>
Invoke the tool.
Parameters ​
• agent: Agent
• args: Args
Arguments for the tool
Returns ​
Promise
<Returns
>
Return value of the tool
Implementation of ​
Throws ​
Error if the arguments are invalid or not supported