agents / Exports / FunctionTool
Class: FunctionTool
Function tool implementation Wraps a JavaScript function as a tool with schema validation
Hierarchy
BaseTool<ToolParameters,ToolResult>↳
FunctionTool
Implements
FunctionTool
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new FunctionTool(schema, fn): FunctionTool
Parameters
| Name | Type |
|---|---|
schema | ToolSchema |
fn | ToolExecutor |
Returns
Overrides
Defined in
packages/agents/src/tools/implementations/function-tool.ts:23
Properties
schema
• Readonly schema: ToolSchema
Implementation of
IFunctionTool.schema
Overrides
Defined in
packages/agents/src/tools/implementations/function-tool.ts:20
fn
• Readonly fn: ToolExecutor
Implementation of
IFunctionTool.fn
Defined in
packages/agents/src/tools/implementations/function-tool.ts:21
Methods
getDescription
▸ getDescription(): string
Returns
string
Implementation of
IFunctionTool.getDescription
Inherited from
Defined in
packages/agents/src/abstracts/base-tool.ts:103
getName
▸ getName(): string
Returns
string
Inherited from
Defined in
packages/agents/src/abstracts/base-tool.ts:107
execute
▸ execute(parameters, context?): Promise<ToolResult>
Execute the function tool
Parameters
| Name | Type |
|---|---|
parameters | ToolParameters |
context? | ToolExecutionContext |
Returns
Promise<ToolResult>
Implementation of
IFunctionTool.execute
Overrides
Defined in
packages/agents/src/tools/implementations/function-tool.ts:33
validate
▸ validate(parameters): boolean
Enhanced validation with detailed error reporting
Parameters
| Name | Type |
|---|---|
parameters | ToolParameters |
Returns
boolean
Implementation of
IFunctionTool.validate
Overrides
Defined in
packages/agents/src/tools/implementations/function-tool.ts:92
validateParameters
▸ validateParameters(parameters): ParameterValidationResult
Validate tool parameters with detailed result
Parameters
| Name | Type |
|---|---|
parameters | ToolParameters |
Returns
Implementation of
IFunctionTool.validateParameters
Overrides
Defined in
packages/agents/src/tools/implementations/function-tool.ts:99