Skip to content

agent-tools / Exports / FunctionTool

Class: FunctionTool

Function tool implementation Wraps a JavaScript function as a tool with schema validation

Implements IFunctionTool without extending AbstractTool to avoid circular runtime dependency (tools → agents → tools).

Implements

  • IFunctionTool

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new FunctionTool(schema, fn): FunctionTool

Parameters

NameType
schemaIToolSchema
fnTToolExecutor

Returns

FunctionTool

Defined in

packages/agent-tools/src/implementations/function-tool.ts:30

Properties

schema

Readonly schema: IToolSchema

Implementation of

IFunctionTool.schema

Defined in

packages/agent-tools/src/implementations/function-tool.ts:26


fn

Readonly fn: TToolExecutor

Implementation of

IFunctionTool.fn

Defined in

packages/agent-tools/src/implementations/function-tool.ts:27

Methods

getName

getName(): string

Get tool name

Returns

string

Defined in

packages/agent-tools/src/implementations/function-tool.ts:39


setEventService

setEventService(eventService): void

Set EventService for post-construction injection. Accepts EventService as-is without transformation. Caller is responsible for providing properly configured EventService.

Parameters

NameType
eventServiceundefined | IEventService

Returns

void

Defined in

packages/agent-tools/src/implementations/function-tool.ts:48


execute

execute(parameters, context?): Promise<IToolResult>

Execute the function tool

Parameters

NameType
parametersTToolParameters
context?IToolExecutionContext

Returns

Promise<IToolResult>

Implementation of

IFunctionTool.execute

Defined in

packages/agent-tools/src/implementations/function-tool.ts:55


validate

validate(parameters): boolean

Validate parameters (simple boolean result)

Parameters

NameType
parametersTToolParameters

Returns

boolean

Implementation of

IFunctionTool.validate

Defined in

packages/agent-tools/src/implementations/function-tool.ts:104


validateParameters

validateParameters(parameters): IParameterValidationResult

Validate tool parameters with detailed result

Parameters

NameType
parametersTToolParameters

Returns

IParameterValidationResult

Implementation of

IFunctionTool.validateParameters

Defined in

packages/agent-tools/src/implementations/function-tool.ts:111


getDescription

getDescription(): string

Get tool description

Returns

string

Implementation of

IFunctionTool.getDescription

Defined in

packages/agent-tools/src/implementations/function-tool.ts:122

Released under the MIT License.