agents / Exports / ErrorHandlingPlugin
Class: ErrorHandlingPlugin
Plugin for handling errors with configurable strategies Provides error recovery, retry mechanisms, and circuit breaker patterns
Hierarchy
AbstractPlugin<ErrorHandlingPluginOptions,ErrorHandlingPluginStats>↳
ErrorHandlingPlugin
Table of contents
Constructors
Properties
Methods
- initialize
- subscribeToModuleEvents
- unsubscribeFromModuleEvents
- dispose
- enable
- disable
- isEnabled
- getConfig
- updateConfig
- getData
- clearData
- getStatus
- beforeRun
- afterRun
- beforeExecution
- afterExecution
- beforeConversation
- afterConversation
- beforeToolCall
- beforeToolExecution
- afterToolCall
- afterToolExecution
- beforeProviderCall
- afterProviderCall
- onStreamingChunk
- onError
- onMessageAdded
- onModuleEvent
- handleError
- executeWithRetry
- resetCircuitBreaker
- getStats
- destroy
Constructors
constructor
• new ErrorHandlingPlugin(options): ErrorHandlingPlugin
Parameters
| Name | Type |
|---|---|
options | ErrorHandlingPluginOptions |
Returns
Overrides
Defined in
packages/agents/src/plugins/error-handling/error-handling-plugin.ts:27
Properties
enabled
• enabled: boolean = true
Plugin enabled state
Inherited from
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:307
category
• category: PluginCategory = PluginCategory.CUSTOM
Plugin category for classification
Inherited from
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:310
priority
• priority: number = PluginPriority.NORMAL
Plugin priority for execution order
Inherited from
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:313
name
• name: string = 'ErrorHandlingPlugin'
Plugin name
Overrides
Defined in
packages/agents/src/plugins/error-handling/error-handling-plugin.ts:18
version
• version: string = '1.0.0'
Plugin version
Overrides
Defined in
packages/agents/src/plugins/error-handling/error-handling-plugin.ts:19
Methods
initialize
▸ initialize(options?): Promise<void>
Initialize the plugin with type-safe options
Parameters
| Name | Type |
|---|---|
options? | ErrorHandlingPluginOptions |
Returns
Promise<void>
Inherited from
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:338
subscribeToModuleEvents
▸ subscribeToModuleEvents(eventEmitter): Promise<void>
Subscribe to module events through EventEmitter
Parameters
| Name | Type |
|---|---|
eventEmitter | EventEmitterPlugin |
Returns
Promise<void>
Inherited from
AbstractPlugin.subscribeToModuleEvents
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:366
unsubscribeFromModuleEvents
▸ unsubscribeFromModuleEvents(eventEmitter): Promise<void>
Unsubscribe from module events
Parameters
| Name | Type |
|---|---|
eventEmitter | EventEmitterPlugin |
Returns
Promise<void>
Inherited from
AbstractPlugin.unsubscribeFromModuleEvents
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:423
dispose
▸ dispose(): Promise<void>
Cleanup plugin resources
Returns
Promise<void>
Inherited from
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:438
enable
▸ enable(): void
Enable the plugin
Returns
void
Inherited from
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:450
disable
▸ disable(): void
Disable the plugin
Returns
void
Inherited from
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:457
isEnabled
▸ isEnabled(): boolean
Check if plugin is enabled
Returns
boolean
Inherited from
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:464
getConfig
▸ getConfig(): IPluginConfig
Get plugin configuration
Returns
Inherited from
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:471
updateConfig
▸ updateConfig(_config): void
Update plugin configuration
Parameters
| Name | Type |
|---|---|
_config | IPluginConfig |
Returns
void
Inherited from
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:478
getData
▸ getData(): IPluginData
Get plugin data - enhanced with classification information
Returns
Inherited from
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:485
clearData
▸ clearData(): void
Clear plugin data - common interface for all plugins This method should be implemented by plugins that store data
Returns
void
Inherited from
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:505
getStatus
▸ getStatus(): Object
Get plugin status - enhanced with classification information
Returns
Object
| Name | Type |
|---|---|
name | string |
version | string |
enabled | boolean |
initialized | boolean |
category | PluginCategory |
priority | number |
subscribedEventsCount | number |
hasEventEmitter | boolean |
Inherited from
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:510
beforeRun
▸ beforeRun(input, options?): Promise<void>
Called before agent run
Parameters
| Name | Type |
|---|---|
input | string |
options? | IRunOptions |
Returns
Promise<void>
Inherited from
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:564
afterRun
▸ afterRun(input, response, options?): Promise<void>
Called after agent run
Parameters
| Name | Type |
|---|---|
input | string |
response | string |
options? | IRunOptions |
Returns
Promise<void>
Inherited from
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:565
beforeExecution
▸ beforeExecution(context): Promise<void>
Called before execution with context
Parameters
| Name | Type |
|---|---|
context | IPluginExecutionContext |
Returns
Promise<void>
Inherited from
AbstractPlugin.beforeExecution
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:566
afterExecution
▸ afterExecution(context, result): Promise<void>
Called after execution with context and result
Parameters
| Name | Type |
|---|---|
context | IPluginExecutionContext |
result | IPluginExecutionResult |
Returns
Promise<void>
Inherited from
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:567
beforeConversation
▸ beforeConversation(context): Promise<void>
Called before conversation with context
Parameters
| Name | Type |
|---|---|
context | IPluginExecutionContext |
Returns
Promise<void>
Inherited from
AbstractPlugin.beforeConversation
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:568
afterConversation
▸ afterConversation(context, result): Promise<void>
Called after conversation with context and result
Parameters
| Name | Type |
|---|---|
context | IPluginExecutionContext |
result | IPluginExecutionResult |
Returns
Promise<void>
Inherited from
AbstractPlugin.afterConversation
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:569
beforeToolCall
▸ beforeToolCall(toolName, parameters): Promise<void>
Called before tool execution
Parameters
| Name | Type |
|---|---|
toolName | string |
parameters | TToolParameters |
Returns
Promise<void>
Inherited from
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:570
beforeToolExecution
▸ beforeToolExecution(context, toolData): Promise<void>
Called before tool execution with context
Parameters
| Name | Type |
|---|---|
context | IPluginExecutionContext |
toolData | IToolExecutionContext |
Returns
Promise<void>
Inherited from
AbstractPlugin.beforeToolExecution
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:571
afterToolCall
▸ afterToolCall(toolName, parameters, result): Promise<void>
Called after tool execution
Parameters
| Name | Type |
|---|---|
toolName | string |
parameters | TToolParameters |
result | IToolExecutionResult |
Returns
Promise<void>
Inherited from
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:572
afterToolExecution
▸ afterToolExecution(context, toolResults): Promise<void>
Called after tool execution with context
Parameters
| Name | Type |
|---|---|
context | IPluginExecutionContext |
toolResults | IPluginExecutionResult |
Returns
Promise<void>
Inherited from
AbstractPlugin.afterToolExecution
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:573
beforeProviderCall
▸ beforeProviderCall(messages): Promise<void>
Called before AI provider call
Parameters
| Name | Type |
|---|---|
messages | TUniversalMessage[] |
Returns
Promise<void>
Inherited from
AbstractPlugin.beforeProviderCall
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:574
afterProviderCall
▸ afterProviderCall(messages, response): Promise<void>
Called after AI provider call
Parameters
| Name | Type |
|---|---|
messages | TUniversalMessage[] |
response | TUniversalMessage |
Returns
Promise<void>
Inherited from
AbstractPlugin.afterProviderCall
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:575
onStreamingChunk
▸ onStreamingChunk(chunk): Promise<void>
Called on streaming chunk
Parameters
| Name | Type |
|---|---|
chunk | TUniversalMessage |
Returns
Promise<void>
Inherited from
AbstractPlugin.onStreamingChunk
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:576
onError
▸ onError(error, context?): Promise<void>
Called on error
Parameters
| Name | Type |
|---|---|
error | Error |
context? | IPluginErrorContext |
Returns
Promise<void>
Inherited from
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:577
onMessageAdded
▸ onMessageAdded(message): Promise<void>
Called on message added to history
Parameters
| Name | Type |
|---|---|
message | TUniversalMessage |
Returns
Promise<void>
Inherited from
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:578
onModuleEvent
▸ onModuleEvent(eventType, eventData): Promise<void>
Called when module events are received
Parameters
| Name | Type |
|---|---|
eventType | EventType |
eventData | EventData |
Returns
Promise<void>
Inherited from
Defined in
packages/agents/src/abstracts/abstract-plugin.ts:579
handleError
▸ handleError(error, context?): Promise<void>
Handle an error with the configured strategy
Parameters
| Name | Type |
|---|---|
error | Error |
context | ErrorHandlingContextData |
Returns
Promise<void>
Defined in
packages/agents/src/plugins/error-handling/error-handling-plugin.ts:61
executeWithRetry
▸ executeWithRetry<T>(fn, context?): Promise<T>
Execute a function with error handling and retry logic REASON: PluginError constructor requires ErrorContextData which has different type constraints than ErrorHandlingContextData, causing multiple type compatibility issues ALTERNATIVES_CONSIDERED: Union types (breaks existing error context interfaces), interface definition (creates circular dependencies), generic types (complex type propagation through error handling chain), conditional types (breaks existing plugin interfaces), mapped types (incompatible with error constructor signatures), type guards (runtime only, doesn't solve constructor compatibility), custom declarations (breaks PluginError interface contract), code refactoring (would require redesigning entire error handling system across all plugins),
Type parameters
| Name |
|---|
T |
Parameters
| Name | Type |
|---|---|
fn | () => Promise<T> |
context | ErrorHandlingContextData |
Returns
Promise<T>
Types
packages (none available for this specific use case), external library integration (no standard error context type systems available), utility types (Pick/Omit create new compatibility issues) TODO: Create unified error context type system that bridges ErrorHandlingContextData and ErrorContextData requirements, or redesign PluginError to accept more flexible context types
Defined in
packages/agents/src/plugins/error-handling/error-handling-plugin.ts:108
resetCircuitBreaker
▸ resetCircuitBreaker(): void
Reset circuit breaker state
Returns
void
Defined in
packages/agents/src/plugins/error-handling/error-handling-plugin.ts:169
getStats
▸ getStats(): ErrorHandlingPluginStats
Get error handling statistics
Returns
ErrorHandlingPluginStats
Overrides
Defined in
packages/agents/src/plugins/error-handling/error-handling-plugin.ts:179
destroy
▸ destroy(): Promise<void>
Cleanup resources
Returns
Promise<void>
Defined in
packages/agents/src/plugins/error-handling/error-handling-plugin.ts:194