Skip to content

agent-core / Exports / AbstractTool

Class: AbstractTool<TParameters, TResult>

Abstract base class for tools with type parameter support Provides type-safe parameter handling and result processing

🎯 ARCHITECTURAL PRINCIPLES:

  • Pure abstract class - depends only on interfaces
  • No concrete class dependencies (EventService interface only)
  • Dependency Injection for all external dependencies
  • Graceful degradation (undefined dependencies = silent operation)

Type parameters

NameTypeDescription
TParametersTToolParametersTool parameters type (defaults to TToolParameters)
TResultIToolResultTool result type (defaults to ToolResult for backward compatibility)

Implements

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new AbstractTool<TParameters, TResult>(options?): AbstractTool<TParameters, TResult>

Constructor with simplified options

🎯 DEPENDENCY INJECTION: All dependencies are injected via options parameter No concrete classes are instantiated within this constructor

Type parameters

NameType
TParametersTToolParameters
TResultIToolResult

Parameters

NameTypeDescription
optionsIAbstractToolOptionsConfiguration options for the tool

Returns

AbstractTool<TParameters, TResult>

Defined in

packages/agent-core/src/abstracts/abstract-tool.ts:150

Properties

schema

Readonly Abstract schema: IToolSchema

Implementation of

IToolWithEventService.schema

Defined in

packages/agent-core/src/abstracts/abstract-tool.ts:128

Methods

setEventService

setEventService(eventService): void

Set EventService for post-construction injection

🎯 DEPENDENCY INJECTION: Accepts EventService as-is without transformation Caller is responsible for providing properly configured EventService

Parameters

NameTypeDescription
eventServiceundefined | IEventServiceEventService instance to use for event emission (or undefined for silent operation)

Returns

void

Implementation of

IToolWithEventService.setEventService

Defined in

packages/agent-core/src/abstracts/abstract-tool.ts:166


execute

execute(parameters, context): Promise<TResult>

Execute tool with simplified lifecycle

Parameters

NameTypeDescription
parametersTParametersTool parameters
contextIToolExecutionContextOptional execution context

Returns

Promise<TResult>

Promise resolving to tool result

Implementation of

IToolWithEventService.execute

Defined in

packages/agent-core/src/abstracts/abstract-tool.ts:198


validate

validate(parameters): boolean

Parameters

NameType
parametersTParameters

Returns

boolean

Implementation of

IToolWithEventService.validate

Defined in

packages/agent-core/src/abstracts/abstract-tool.ts:215


validateParameters

validateParameters(parameters): IParameterValidationResult

Validate tool parameters with detailed result (default implementation)

Parameters

NameType
parametersTParameters

Returns

IParameterValidationResult

Implementation of

IToolWithEventService.validateParameters

Defined in

packages/agent-core/src/abstracts/abstract-tool.ts:225


getDescription

getDescription(): string

Returns

string

Implementation of

IToolWithEventService.getDescription

Defined in

packages/agent-core/src/abstracts/abstract-tool.ts:242


getName

getName(): string

Returns

string

Implementation of

IToolWithEventService.getName

Defined in

packages/agent-core/src/abstracts/abstract-tool.ts:246

Released under the MIT License.