<!--
 ⚠️  AUTO-GENERATED FILE - DO NOT EDIT MANUALLY
 This file is automatically generated by scripts/docs-generator.js
 To make changes, edit the source TypeScript files or update the generator script
-->

[agents](../../) / [Exports](../modules) / IPluginHooks

# Interface: IPluginHooks

Plugin lifecycle hooks

## Implemented by

- [`AbstractPlugin`](../classes/AbstractPlugin)

## Table of contents

### Methods

- [beforeRun](IPluginHooks#beforerun)
- [afterRun](IPluginHooks#afterrun)
- [beforeExecution](IPluginHooks#beforeexecution)
- [afterExecution](IPluginHooks#afterexecution)
- [beforeConversation](IPluginHooks#beforeconversation)
- [afterConversation](IPluginHooks#afterconversation)
- [beforeToolCall](IPluginHooks#beforetoolcall)
- [beforeToolExecution](IPluginHooks#beforetoolexecution)
- [afterToolCall](IPluginHooks#aftertoolcall)
- [afterToolExecution](IPluginHooks#aftertoolexecution)
- [beforeProviderCall](IPluginHooks#beforeprovidercall)
- [afterProviderCall](IPluginHooks#afterprovidercall)
- [onStreamingChunk](IPluginHooks#onstreamingchunk)
- [onError](IPluginHooks#onerror)
- [onMessageAdded](IPluginHooks#onmessageadded)
- [onModuleEvent](IPluginHooks#onmoduleevent)

## Methods

### beforeRun

▸ **beforeRun**(`input`, `options?`): `void` \| `Promise`\<`void`\>

Called before agent run

#### Parameters

| Name       | Type                         |
| :--------- | :--------------------------- |
| `input`    | `string`                     |
| `options?` | [`IRunOptions`](IRunOptions) |

#### Returns

`void` \| `Promise`\<`void`\>

#### Defined in

[packages/agents/src/abstracts/abstract-plugin.ts:207](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/abstracts/abstract-plugin.ts#L207)

---

### afterRun

▸ **afterRun**(`input`, `response`, `options?`): `void` \| `Promise`\<`void`\>

Called after agent run

#### Parameters

| Name       | Type                         |
| :--------- | :--------------------------- |
| `input`    | `string`                     |
| `response` | `string`                     |
| `options?` | [`IRunOptions`](IRunOptions) |

#### Returns

`void` \| `Promise`\<`void`\>

#### Defined in

[packages/agents/src/abstracts/abstract-plugin.ts:212](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/abstracts/abstract-plugin.ts#L212)

---

### beforeExecution

▸ **beforeExecution**(`context`): `void` \| `Promise`\<`void`\>

Called before execution with context

#### Parameters

| Name      | Type                                                 |
| :-------- | :--------------------------------------------------- |
| `context` | [`IPluginExecutionContext`](IPluginExecutionContext) |

#### Returns

`void` \| `Promise`\<`void`\>

#### Defined in

[packages/agents/src/abstracts/abstract-plugin.ts:217](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/abstracts/abstract-plugin.ts#L217)

---

### afterExecution

▸ **afterExecution**(`context`, `result`): `void` \| `Promise`\<`void`\>

Called after execution with context and result

#### Parameters

| Name      | Type                                                 |
| :-------- | :--------------------------------------------------- |
| `context` | [`IPluginExecutionContext`](IPluginExecutionContext) |
| `result`  | [`IPluginExecutionResult`](IPluginExecutionResult)   |

#### Returns

`void` \| `Promise`\<`void`\>

#### Defined in

[packages/agents/src/abstracts/abstract-plugin.ts:222](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/abstracts/abstract-plugin.ts#L222)

---

### beforeConversation

▸ **beforeConversation**(`context`): `void` \| `Promise`\<`void`\>

Called before conversation with context

#### Parameters

| Name      | Type                                                 |
| :-------- | :--------------------------------------------------- |
| `context` | [`IPluginExecutionContext`](IPluginExecutionContext) |

#### Returns

`void` \| `Promise`\<`void`\>

#### Defined in

[packages/agents/src/abstracts/abstract-plugin.ts:227](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/abstracts/abstract-plugin.ts#L227)

---

### afterConversation

▸ **afterConversation**(`context`, `result`): `void` \| `Promise`\<`void`\>

Called after conversation with context and result

#### Parameters

| Name      | Type                                                 |
| :-------- | :--------------------------------------------------- |
| `context` | [`IPluginExecutionContext`](IPluginExecutionContext) |
| `result`  | [`IPluginExecutionResult`](IPluginExecutionResult)   |

#### Returns

`void` \| `Promise`\<`void`\>

#### Defined in

[packages/agents/src/abstracts/abstract-plugin.ts:232](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/abstracts/abstract-plugin.ts#L232)

---

### beforeToolCall

▸ **beforeToolCall**(`toolName`, `parameters`): `void` \| `Promise`\<`void`\>

Called before tool execution

#### Parameters

| Name         | Type                                            |
| :----------- | :---------------------------------------------- |
| `toolName`   | `string`                                        |
| `parameters` | [`TToolParameters`](../modules#ttoolparameters) |

#### Returns

`void` \| `Promise`\<`void`\>

#### Defined in

[packages/agents/src/abstracts/abstract-plugin.ts:237](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/abstracts/abstract-plugin.ts#L237)

---

### beforeToolExecution

▸ **beforeToolExecution**(`context`, `toolData`): `void` \| `Promise`\<`void`\>

Called before tool execution with context

#### Parameters

| Name       | Type                                                 |
| :--------- | :--------------------------------------------------- |
| `context`  | [`IPluginExecutionContext`](IPluginExecutionContext) |
| `toolData` | [`IToolExecutionContext`](IToolExecutionContext)     |

#### Returns

`void` \| `Promise`\<`void`\>

#### Defined in

[packages/agents/src/abstracts/abstract-plugin.ts:242](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/abstracts/abstract-plugin.ts#L242)

---

### afterToolCall

▸ **afterToolCall**(`toolName`, `parameters`, `result`): `void` \| `Promise`\<`void`\>

Called after tool execution

#### Parameters

| Name         | Type                                            |
| :----------- | :---------------------------------------------- |
| `toolName`   | `string`                                        |
| `parameters` | [`TToolParameters`](../modules#ttoolparameters) |
| `result`     | [`IToolExecutionResult`](IToolExecutionResult)  |

#### Returns

`void` \| `Promise`\<`void`\>

#### Defined in

[packages/agents/src/abstracts/abstract-plugin.ts:247](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/abstracts/abstract-plugin.ts#L247)

---

### afterToolExecution

▸ **afterToolExecution**(`context`, `toolResults`): `void` \| `Promise`\<`void`\>

Called after tool execution with context

#### Parameters

| Name          | Type                                                 |
| :------------ | :--------------------------------------------------- |
| `context`     | [`IPluginExecutionContext`](IPluginExecutionContext) |
| `toolResults` | [`IPluginExecutionResult`](IPluginExecutionResult)   |

#### Returns

`void` \| `Promise`\<`void`\>

#### Defined in

[packages/agents/src/abstracts/abstract-plugin.ts:252](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/abstracts/abstract-plugin.ts#L252)

---

### beforeProviderCall

▸ **beforeProviderCall**(`messages`): `void` \| `Promise`\<`void`\>

Called before AI provider call

#### Parameters

| Name       | Type                                                  |
| :--------- | :---------------------------------------------------- |
| `messages` | [`TUniversalMessage`](../modules#tuniversalmessage)[] |

#### Returns

`void` \| `Promise`\<`void`\>

#### Defined in

[packages/agents/src/abstracts/abstract-plugin.ts:257](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/abstracts/abstract-plugin.ts#L257)

---

### afterProviderCall

▸ **afterProviderCall**(`messages`, `response`): `void` \| `Promise`\<`void`\>

Called after AI provider call

#### Parameters

| Name       | Type                                                  |
| :--------- | :---------------------------------------------------- |
| `messages` | [`TUniversalMessage`](../modules#tuniversalmessage)[] |
| `response` | [`TUniversalMessage`](../modules#tuniversalmessage)   |

#### Returns

`void` \| `Promise`\<`void`\>

#### Defined in

[packages/agents/src/abstracts/abstract-plugin.ts:262](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/abstracts/abstract-plugin.ts#L262)

---

### onStreamingChunk

▸ **onStreamingChunk**(`chunk`): `void` \| `Promise`\<`void`\>

Called on streaming chunk

#### Parameters

| Name    | Type                                                |
| :------ | :-------------------------------------------------- |
| `chunk` | [`TUniversalMessage`](../modules#tuniversalmessage) |

#### Returns

`void` \| `Promise`\<`void`\>

#### Defined in

[packages/agents/src/abstracts/abstract-plugin.ts:267](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/abstracts/abstract-plugin.ts#L267)

---

### onError

▸ **onError**(`error`, `context?`): `void` \| `Promise`\<`void`\>

Called on error

#### Parameters

| Name       | Type                                         |
| :--------- | :------------------------------------------- |
| `error`    | `Error`                                      |
| `context?` | [`IPluginErrorContext`](IPluginErrorContext) |

#### Returns

`void` \| `Promise`\<`void`\>

#### Defined in

[packages/agents/src/abstracts/abstract-plugin.ts:272](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/abstracts/abstract-plugin.ts#L272)

---

### onMessageAdded

▸ **onMessageAdded**(`message`): `void` \| `Promise`\<`void`\>

Called on message added to history

#### Parameters

| Name      | Type                                                |
| :-------- | :-------------------------------------------------- |
| `message` | [`TUniversalMessage`](../modules#tuniversalmessage) |

#### Returns

`void` \| `Promise`\<`void`\>

#### Defined in

[packages/agents/src/abstracts/abstract-plugin.ts:277](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/abstracts/abstract-plugin.ts#L277)

---

### onModuleEvent

▸ **onModuleEvent**(`eventType`, `eventData`): `void` \| `Promise`\<`void`\>

Called when module events are received

#### Parameters

| Name        | Type                                |
| :---------- | :---------------------------------- |
| `eventType` | [`EventType`](../modules#eventtype) |
| `eventData` | [`EventData`](EventData)            |

#### Returns

`void` \| `Promise`\<`void`\>

#### Defined in

[packages/agents/src/abstracts/abstract-plugin.ts:282](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/abstracts/abstract-plugin.ts#L282)
