<!--
 ⚠️  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) / FunctionTool

# Class: FunctionTool

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

## Hierarchy

- `AbstractTool`\<[`TToolParameters`](../modules#ttoolparameters), [`IToolResult`](../interfaces/IToolResult)\>

  ↳ **`FunctionTool`**

## Implements

- [`IFunctionTool`](../interfaces/IFunctionTool)

## Table of contents

### Constructors

- [constructor](FunctionTool#constructor)

### Properties

- [schema](FunctionTool#schema)
- [fn](FunctionTool#fn)

### Methods

- [setEventService](FunctionTool#seteventservice)
- [execute](FunctionTool#execute)
- [getDescription](FunctionTool#getdescription)
- [getName](FunctionTool#getname)
- [validate](FunctionTool#validate)
- [validateParameters](FunctionTool#validateparameters)

## Constructors

### constructor

• **new FunctionTool**(`schema`, `fn`, `options?`): [`FunctionTool`](FunctionTool)

#### Parameters

| Name      | Type                                        |
| :-------- | :------------------------------------------ |
| `schema`  | [`IToolSchema`](../interfaces/IToolSchema)  |
| `fn`      | [`TToolExecutor`](../modules#ttoolexecutor) |
| `options` | `IAbstractToolOptions`                      |

#### Returns

[`FunctionTool`](FunctionTool)

#### Overrides

AbstractTool\&lt;TToolParameters, IToolResult\&gt;.constructor

#### Defined in

[packages/agents/src/tools/implementations/function-tool.ts:23](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/tools/implementations/function-tool.ts#L23)

## Properties

### schema

• `Readonly` **schema**: [`IToolSchema`](../interfaces/IToolSchema)

Tool schema

#### Implementation of

[IFunctionTool](../interfaces/IFunctionTool).[schema](../interfaces/IFunctionTool#schema)

#### Overrides

AbstractTool.schema

#### Defined in

[packages/agents/src/tools/implementations/function-tool.ts:20](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/tools/implementations/function-tool.ts#L20)

---

### fn

• `Readonly` **fn**: [`TToolExecutor`](../modules#ttoolexecutor)

Function to execute

#### Implementation of

[IFunctionTool](../interfaces/IFunctionTool).[fn](../interfaces/IFunctionTool#fn)

#### Defined in

[packages/agents/src/tools/implementations/function-tool.ts:21](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/tools/implementations/function-tool.ts#L21)

## 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

| Name           | Type                                                          | Description                                                                         |
| :------------- | :------------------------------------------------------------ | :---------------------------------------------------------------------------------- |
| `eventService` | `undefined` \| [`IEventService`](../interfaces/IEventService) | EventService instance to use for event emission (or undefined for silent operation) |

#### Returns

`void`

#### Inherited from

AbstractTool.setEventService

#### Defined in

[packages/agents/src/abstracts/abstract-tool.ts:152](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/abstracts/abstract-tool.ts#L152)

---

### execute

▸ **execute**(`parameters`, `context`): `Promise`\<[`IToolResult`](../interfaces/IToolResult)\>

Execute tool with simplified lifecycle

#### Parameters

| Name         | Type                                                           | Description                |
| :----------- | :------------------------------------------------------------- | :------------------------- |
| `parameters` | [`TToolParameters`](../modules#ttoolparameters)                | Tool parameters            |
| `context`    | [`IToolExecutionContext`](../interfaces/IToolExecutionContext) | Optional execution context |

#### Returns

`Promise`\<[`IToolResult`](../interfaces/IToolResult)\>

Promise resolving to tool result

#### Implementation of

[IFunctionTool](../interfaces/IFunctionTool).[execute](../interfaces/IFunctionTool#execute)

#### Inherited from

AbstractTool.execute

#### Defined in

[packages/agents/src/abstracts/abstract-tool.ts:184](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/abstracts/abstract-tool.ts#L184)

---

### getDescription

▸ **getDescription**(): `string`

Get tool description

#### Returns

`string`

#### Implementation of

[IFunctionTool](../interfaces/IFunctionTool).[getDescription](../interfaces/IFunctionTool#getdescription)

#### Inherited from

AbstractTool.getDescription

#### Defined in

[packages/agents/src/abstracts/abstract-tool.ts:223](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/abstracts/abstract-tool.ts#L223)

---

### getName

▸ **getName**(): `string`

#### Returns

`string`

#### Inherited from

AbstractTool.getName

#### Defined in

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

---

### validate

▸ **validate**(`parameters`): `boolean`

Enhanced validation with detailed error reporting

#### Parameters

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

#### Returns

`boolean`

#### Implementation of

[IFunctionTool](../interfaces/IFunctionTool).[validate](../interfaces/IFunctionTool#validate)

#### Overrides

AbstractTool.validate

#### Defined in

[packages/agents/src/tools/implementations/function-tool.ts:97](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/tools/implementations/function-tool.ts#L97)

---

### validateParameters

▸ **validateParameters**(`parameters`): [`IParameterValidationResult`](../interfaces/IParameterValidationResult)

Validate tool parameters with detailed result

#### Parameters

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

#### Returns

[`IParameterValidationResult`](../interfaces/IParameterValidationResult)

#### Implementation of

[IFunctionTool](../interfaces/IFunctionTool).[validateParameters](../interfaces/IFunctionTool#validateparameters)

#### Overrides

AbstractTool.validateParameters

#### Defined in

[packages/agents/src/tools/implementations/function-tool.ts:104](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/tools/implementations/function-tool.ts#L104)
