@voltagent/core 1.1.37 → 1.1.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { ModelMessage, DataContent as DataContent$1, UserContent, AssistantContent, ToolContent, ProviderOptions as ProviderOptions$1 } from '@ai-sdk/provider-utils';
1
+ import { ModelMessage, ToolCallOptions, DataContent as DataContent$1, UserContent, AssistantContent, ToolContent, ProviderOptions as ProviderOptions$1 } from '@ai-sdk/provider-utils';
2
2
  export { AssistantContent, FilePart, ImagePart, TextPart, ToolContent, UserContent } from '@ai-sdk/provider-utils';
3
3
  import { Tool as Tool$1, TextStreamPart, generateText, UIMessage, StreamTextResult, LanguageModel, CallSettings, Output, ToolSet, GenerateTextResult, GenerateObjectResult, AsyncIterableStream as AsyncIterableStream$1, CallWarning, LanguageModelUsage, FinishReason, EmbeddingModel } from 'ai';
4
4
  export { LanguageModel, Tool as VercelTool, hasToolCall, stepCountIs } from 'ai';
@@ -58,95 +58,164 @@ type Toolkit = {
58
58
  */
59
59
  declare const createToolkit: (options: Toolkit) => Toolkit;
60
60
 
61
- /**
62
- * Status of a tool at any given time
63
- */
64
- type ToolStatus = "idle" | "working" | "error" | "completed";
65
- /**
66
- * Tool status information
67
- */
68
- type ToolStatusInfo = {
69
- name: string;
70
- status: ToolStatus;
71
- result?: any;
72
- error?: any;
73
- input?: any;
74
- output?: any;
75
- timestamp: Date;
76
- parameters?: any;
77
- };
78
- /**
79
- * Manager class to handle all tool-related operations, including Toolkits.
80
- */
81
- declare class ToolManager {
61
+ declare abstract class BaseToolManager<TItems extends AgentTool | Tool$1 | Toolkit = AgentTool | Tool$1 | Toolkit, TToolkitManager extends BaseToolManager<TItems, never> | never = BaseToolManager<TItems, never>> {
82
62
  /**
83
63
  * User tools managed by this manager.
84
64
  * Includes server-side and client-side tools (no server execute) managed separately from server-executable tools.
85
65
  */
86
- private baseTools;
66
+ protected baseTools: Map<string, BaseTool>;
87
67
  /**
88
68
  * Provider-defined tools managed by providers
89
69
  */
90
- private providerTools;
70
+ protected providerTools: Map<string, ProviderTool>;
91
71
  /**
92
72
  * Toolkits managed by this manager.
93
73
  */
94
- private toolkits;
74
+ protected toolkits: Map<string, TToolkitManager>;
95
75
  /**
96
76
  * Logger instance
97
77
  */
98
- private logger;
78
+ protected logger: Logger;
99
79
  /**
100
80
  * Creates a new ToolManager.
101
81
  * Accepts individual tools, provider-defined tools, and toolkits.
102
82
  */
103
- constructor(items?: (AgentTool | Tool$1 | Toolkit)[], logger?: Logger);
83
+ protected constructor(items?: TItems[], logger?: Logger);
84
+ /** Not all inheritances of BaseToolManager support toolkits - thus this is abstract */
85
+ abstract addToolkit(toolkit: Toolkit): boolean;
86
+ /**
87
+ * Add multiple tools or toolkits to the manager.
88
+ */
89
+ addItems(items: TItems[]): void;
90
+ addStandaloneTool(tool: AgentTool | Tool$1): boolean;
91
+ /**
92
+ * Remove a standalone tool by name. Does not remove tools from toolkits.
93
+ * @returns true if the tool was removed, false if it wasn't found.
94
+ */
95
+ removeTool(toolName: string): boolean;
96
+ /**
97
+ * Remove a toolkit by name.
98
+ * @returns true if the toolkit was removed, false if it wasn't found.
99
+ */
100
+ removeToolkit(toolkitName: string): boolean;
104
101
  /**
105
102
  * Get all toolkits managed by this manager.
106
103
  */
107
- getToolkits(): Toolkit[];
104
+ getToolkits(): TToolkitManager[];
105
+ /**
106
+ * Get standalone tools and standalone tools within toolkits as a flattened list.
107
+ */
108
+ getAllBaseTools(): BaseTool[];
108
109
  /**
109
110
  * Get provider-defined tools managed externally by providers.
110
111
  */
111
- getProviderTools(): ProviderTool[];
112
- addTool(tool: AgentTool | Tool$1): boolean;
113
- hasTool(toolName: string): boolean;
112
+ getAllProviderTools(): ProviderTool[];
114
113
  /**
115
- * Add multiple tools or toolkits to the manager.
114
+ * Get all kinds of tools, owned by this manager and inside toolkits as a flattened list.
115
+ * */
116
+ getAllTools(): (BaseTool | ProviderTool)[];
117
+ /**
118
+ * Get names of all tools (standalone and inside toolkits), deduplicated.
116
119
  */
117
- addItems(items: (AgentTool | Tool$1 | Toolkit)[]): void;
120
+ getAllToolNames(): string[];
118
121
  /**
119
- * Get all individual tools and tools within toolkits as a flattened list.
122
+ * Returns tools owned directly by this manager (standalone tools), excluding tools inside toolkits.
120
123
  */
121
- getTools(): BaseTool[];
124
+ protected getStandaloneTools(): (BaseTool | ProviderTool)[];
122
125
  /**
123
- * Add a toolkit to the manager.
124
- * If a toolkit with the same name already exists, it will be replaced.
125
- * Also checks if any tool within the toolkit conflicts with existing standalone tools or tools in other toolkits.
126
- * @returns true if the toolkit was successfully added or replaced.
126
+ * Check if any tool with the given name exists in this manager or nested toolkits.
127
127
  */
128
- addToolkit(toolkit: Toolkit): boolean;
129
- findInToolkits(toolName: string): Tool | ProviderTool | false;
128
+ hasToolInAny(toolName: string): boolean;
129
+ }
130
+
131
+ declare class ToolkitManager extends BaseToolManager<AgentTool | Tool$1, never> {
132
+ readonly name: string;
130
133
  /**
131
- * Remove a standalone tool by name. Does not remove tools from toolkits.
132
- * @returns true if the tool was removed, false if it wasn't found.
134
+ * A brief description of what the toolkit does or what tools it contains.
135
+ * Optional.
133
136
  */
134
- removeTool(toolName: string): boolean;
137
+ readonly description?: string | undefined;
135
138
  /**
136
- * Remove a toolkit by name.
137
- * @returns true if the toolkit was removed, false if it wasn't found.
139
+ * Shared instructions for the LLM on how to use the tools within this toolkit.
140
+ * These instructions are intended to be added to the system prompt if `addInstructions` is true.
141
+ * Optional.
138
142
  */
139
- removeToolkit(toolkitName: string): boolean;
143
+ readonly instructions?: string | undefined;
144
+ /**
145
+ * Whether to automatically add the toolkit's `instructions` to the agent's system prompt.
146
+ * If true, the instructions from individual tools within this toolkit might be ignored
147
+ * by the Agent's system message generation logic to avoid redundancy.
148
+ * Defaults to false.
149
+ */
150
+ readonly addInstructions: boolean;
151
+ /**
152
+ * Constructor does not accept toolkits - only tools
153
+ * */
154
+ constructor(name: string, items?: (AgentTool | Tool$1)[],
155
+ /**
156
+ * A brief description of what the toolkit does or what tools it contains.
157
+ * Optional.
158
+ */
159
+ description?: string | undefined,
160
+ /**
161
+ * Shared instructions for the LLM on how to use the tools within this toolkit.
162
+ * These instructions are intended to be added to the system prompt if `addInstructions` is true.
163
+ * Optional.
164
+ */
165
+ instructions?: string | undefined,
166
+ /**
167
+ * Whether to automatically add the toolkit's `instructions` to the agent's system prompt.
168
+ * If true, the instructions from individual tools within this toolkit might be ignored
169
+ * by the Agent's system message generation logic to avoid redundancy.
170
+ * Defaults to false.
171
+ */
172
+ addInstructions?: boolean, logger?: Logger);
173
+ /**
174
+ * Toolkits are not supported inside a ToolkitManager (toolkits contain tools only).
175
+ * Keep the same signature as BaseToolManager.addToolkit to preserve type compatibility,
176
+ * but implement as a no-op (or warn) so callers won't crash.
177
+ */
178
+ addToolkit(toolkit: Toolkit): boolean;
179
+ }
180
+
181
+ declare class ToolManager extends BaseToolManager<AgentTool | Tool$1 | Toolkit, ToolkitManager> {
182
+ /**
183
+ * Creates a new ToolManager.
184
+ * Accepts individual tools, provider-defined tools, and toolkits.
185
+ */
186
+ constructor(items?: (AgentTool | Tool$1 | Toolkit)[], logger?: Logger);
140
187
  /**
141
- * Combine static base tools with runtime tools (includes tools from toolkits).
188
+ * Add a toolkit to the manager.
189
+ * If a toolkit with the same name already exists, it will be replaced.
190
+ * Also checks if any tool within the toolkit conflicts with existing standalone tools or tools in other toolkits.
191
+ * @returns true if the toolkit was successfully added or replaced.
142
192
  */
143
- combineStaticAndRuntimeBaseTools(runtimeTools?: (BaseTool | Toolkit)[]): BaseTool[];
193
+ addToolkit(toolkit: Toolkit): boolean;
194
+ prepareToolsForExecution(createToolExecuteFunction: (tool: AgentTool) => (args: any, options?: ToolExecuteOptions) => Promise<any>): Record<string, any>;
144
195
  /**
145
196
  * Get agent's tools (including those in toolkits) for API exposure.
146
197
  */
147
198
  getToolsForApi(): ApiToolInfo[];
148
199
  }
149
200
 
201
+ /**
202
+ * Status of a tool at any given time
203
+ */
204
+ type ToolStatus = "idle" | "working" | "error" | "completed";
205
+ /**
206
+ * Tool status information
207
+ */
208
+ type ToolStatusInfo = {
209
+ name: string;
210
+ status: ToolStatus;
211
+ result?: any;
212
+ error?: any;
213
+ input?: any;
214
+ output?: any;
215
+ timestamp: Date;
216
+ parameters?: any;
217
+ };
218
+
150
219
  /**
151
220
  * Tool definition compatible with Vercel AI SDK
152
221
  */
@@ -184,7 +253,7 @@ type ToolOptions<T extends ToolSchema = ToolSchema, O extends ToolSchema | undef
184
253
  /**
185
254
  * Function to execute when the tool is called
186
255
  */
187
- execute?: (args: z.infer<T>, context?: OperationContext) => Promise<O extends ToolSchema ? z.infer<O> : unknown>;
256
+ execute?: (args: z.infer<T>, context?: OperationContext, options?: ToolExecuteOptions) => Promise<O extends ToolSchema ? z.infer<O> : unknown>;
188
257
  };
189
258
  /**
190
259
  * Tool class for defining tools that agents can use
@@ -218,7 +287,7 @@ declare class Tool<T extends ToolSchema = ToolSchema, O extends ToolSchema | und
218
287
  /**
219
288
  * Function to execute when the tool is called
220
289
  */
221
- readonly execute?: (args: z.infer<T>, context?: OperationContext) => Promise<O extends ToolSchema ? z.infer<O> : unknown>;
290
+ readonly execute?: (args: z.infer<T>, context?: OperationContext, options?: ToolExecuteOptions) => Promise<O extends ToolSchema ? z.infer<O> : unknown>;
222
291
  /**
223
292
  * Whether this tool should be executed on the client side.
224
293
  * Returns true when no server-side execute handler is provided.
@@ -416,24 +485,23 @@ type MessageRole = "user" | "assistant" | "system" | "tool";
416
485
  */
417
486
  type BaseMessage = ModelMessage;
418
487
  type ToolSchema = z.ZodType;
419
- type ToolExecuteOptions = {
488
+ type ToolExecuteOptions = ToolCallOptions & {
420
489
  /**
421
- * Optional AbortController for cancelling the execution and accessing the signal
490
+ * Optional AbortController for cancelling the execution and accessing the signal.
491
+ * Prefer using the provided abortSignal, but we keep this for backward compatibility.
422
492
  */
423
493
  abortController?: AbortController;
424
494
  /**
425
- * @deprecated Use abortController.signal instead. This field will be removed in a future version.
426
- * Optional AbortSignal to abort the execution
495
+ * @deprecated Use abortController.signal or options.abortSignal instead. This field will be removed in a future version.
427
496
  */
428
497
  signal?: AbortSignal;
429
498
  /**
430
499
  * The operation context associated with the agent invocation triggering this tool execution.
431
- * Provides access to operation-specific state like context.
432
- * The context includes a logger with full execution context (userId, conversationId, executionId).
500
+ * Provides access to operation-specific state like context and logging metadata.
433
501
  */
434
502
  operationContext?: OperationContext;
435
503
  /**
436
- * Additional options can be added in the future
504
+ * Additional options can be added in the future.
437
505
  */
438
506
  [key: string]: any;
439
507
  };
@@ -3390,6 +3458,7 @@ interface OnToolStartHookArgs {
3390
3458
  tool: AgentTool;
3391
3459
  context: OperationContext;
3392
3460
  args: any;
3461
+ options?: ToolExecuteOptions;
3393
3462
  }
3394
3463
  interface OnToolEndHookArgs {
3395
3464
  agent: Agent;
@@ -3399,6 +3468,7 @@ interface OnToolEndHookArgs {
3399
3468
  /** The error if the tool execution failed. */
3400
3469
  error: VoltAgentError | AbortError | undefined;
3401
3470
  context: OperationContext;
3471
+ options?: ToolExecuteOptions;
3402
3472
  }
3403
3473
  interface OnPrepareMessagesHookArgs {
3404
3474
  /** The messages that will be sent to the LLM (AI SDK UIMessage). */
@@ -4529,10 +4599,7 @@ declare class Agent {
4529
4599
  * Validate tool output against optional output schema.
4530
4600
  */
4531
4601
  private validateToolOutput;
4532
- /**
4533
- * Convert VoltAgent tools to AI SDK format with context injection
4534
- */
4535
- private convertTools;
4602
+ private createToolExecutionFactory;
4536
4603
  /**
4537
4604
  * Create step handler for memory and hooks
4538
4605
  */
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ModelMessage, DataContent as DataContent$1, UserContent, AssistantContent, ToolContent, ProviderOptions as ProviderOptions$1 } from '@ai-sdk/provider-utils';
1
+ import { ModelMessage, ToolCallOptions, DataContent as DataContent$1, UserContent, AssistantContent, ToolContent, ProviderOptions as ProviderOptions$1 } from '@ai-sdk/provider-utils';
2
2
  export { AssistantContent, FilePart, ImagePart, TextPart, ToolContent, UserContent } from '@ai-sdk/provider-utils';
3
3
  import { Tool as Tool$1, TextStreamPart, generateText, UIMessage, StreamTextResult, LanguageModel, CallSettings, Output, ToolSet, GenerateTextResult, GenerateObjectResult, AsyncIterableStream as AsyncIterableStream$1, CallWarning, LanguageModelUsage, FinishReason, EmbeddingModel } from 'ai';
4
4
  export { LanguageModel, Tool as VercelTool, hasToolCall, stepCountIs } from 'ai';
@@ -58,95 +58,164 @@ type Toolkit = {
58
58
  */
59
59
  declare const createToolkit: (options: Toolkit) => Toolkit;
60
60
 
61
- /**
62
- * Status of a tool at any given time
63
- */
64
- type ToolStatus = "idle" | "working" | "error" | "completed";
65
- /**
66
- * Tool status information
67
- */
68
- type ToolStatusInfo = {
69
- name: string;
70
- status: ToolStatus;
71
- result?: any;
72
- error?: any;
73
- input?: any;
74
- output?: any;
75
- timestamp: Date;
76
- parameters?: any;
77
- };
78
- /**
79
- * Manager class to handle all tool-related operations, including Toolkits.
80
- */
81
- declare class ToolManager {
61
+ declare abstract class BaseToolManager<TItems extends AgentTool | Tool$1 | Toolkit = AgentTool | Tool$1 | Toolkit, TToolkitManager extends BaseToolManager<TItems, never> | never = BaseToolManager<TItems, never>> {
82
62
  /**
83
63
  * User tools managed by this manager.
84
64
  * Includes server-side and client-side tools (no server execute) managed separately from server-executable tools.
85
65
  */
86
- private baseTools;
66
+ protected baseTools: Map<string, BaseTool>;
87
67
  /**
88
68
  * Provider-defined tools managed by providers
89
69
  */
90
- private providerTools;
70
+ protected providerTools: Map<string, ProviderTool>;
91
71
  /**
92
72
  * Toolkits managed by this manager.
93
73
  */
94
- private toolkits;
74
+ protected toolkits: Map<string, TToolkitManager>;
95
75
  /**
96
76
  * Logger instance
97
77
  */
98
- private logger;
78
+ protected logger: Logger;
99
79
  /**
100
80
  * Creates a new ToolManager.
101
81
  * Accepts individual tools, provider-defined tools, and toolkits.
102
82
  */
103
- constructor(items?: (AgentTool | Tool$1 | Toolkit)[], logger?: Logger);
83
+ protected constructor(items?: TItems[], logger?: Logger);
84
+ /** Not all inheritances of BaseToolManager support toolkits - thus this is abstract */
85
+ abstract addToolkit(toolkit: Toolkit): boolean;
86
+ /**
87
+ * Add multiple tools or toolkits to the manager.
88
+ */
89
+ addItems(items: TItems[]): void;
90
+ addStandaloneTool(tool: AgentTool | Tool$1): boolean;
91
+ /**
92
+ * Remove a standalone tool by name. Does not remove tools from toolkits.
93
+ * @returns true if the tool was removed, false if it wasn't found.
94
+ */
95
+ removeTool(toolName: string): boolean;
96
+ /**
97
+ * Remove a toolkit by name.
98
+ * @returns true if the toolkit was removed, false if it wasn't found.
99
+ */
100
+ removeToolkit(toolkitName: string): boolean;
104
101
  /**
105
102
  * Get all toolkits managed by this manager.
106
103
  */
107
- getToolkits(): Toolkit[];
104
+ getToolkits(): TToolkitManager[];
105
+ /**
106
+ * Get standalone tools and standalone tools within toolkits as a flattened list.
107
+ */
108
+ getAllBaseTools(): BaseTool[];
108
109
  /**
109
110
  * Get provider-defined tools managed externally by providers.
110
111
  */
111
- getProviderTools(): ProviderTool[];
112
- addTool(tool: AgentTool | Tool$1): boolean;
113
- hasTool(toolName: string): boolean;
112
+ getAllProviderTools(): ProviderTool[];
114
113
  /**
115
- * Add multiple tools or toolkits to the manager.
114
+ * Get all kinds of tools, owned by this manager and inside toolkits as a flattened list.
115
+ * */
116
+ getAllTools(): (BaseTool | ProviderTool)[];
117
+ /**
118
+ * Get names of all tools (standalone and inside toolkits), deduplicated.
116
119
  */
117
- addItems(items: (AgentTool | Tool$1 | Toolkit)[]): void;
120
+ getAllToolNames(): string[];
118
121
  /**
119
- * Get all individual tools and tools within toolkits as a flattened list.
122
+ * Returns tools owned directly by this manager (standalone tools), excluding tools inside toolkits.
120
123
  */
121
- getTools(): BaseTool[];
124
+ protected getStandaloneTools(): (BaseTool | ProviderTool)[];
122
125
  /**
123
- * Add a toolkit to the manager.
124
- * If a toolkit with the same name already exists, it will be replaced.
125
- * Also checks if any tool within the toolkit conflicts with existing standalone tools or tools in other toolkits.
126
- * @returns true if the toolkit was successfully added or replaced.
126
+ * Check if any tool with the given name exists in this manager or nested toolkits.
127
127
  */
128
- addToolkit(toolkit: Toolkit): boolean;
129
- findInToolkits(toolName: string): Tool | ProviderTool | false;
128
+ hasToolInAny(toolName: string): boolean;
129
+ }
130
+
131
+ declare class ToolkitManager extends BaseToolManager<AgentTool | Tool$1, never> {
132
+ readonly name: string;
130
133
  /**
131
- * Remove a standalone tool by name. Does not remove tools from toolkits.
132
- * @returns true if the tool was removed, false if it wasn't found.
134
+ * A brief description of what the toolkit does or what tools it contains.
135
+ * Optional.
133
136
  */
134
- removeTool(toolName: string): boolean;
137
+ readonly description?: string | undefined;
135
138
  /**
136
- * Remove a toolkit by name.
137
- * @returns true if the toolkit was removed, false if it wasn't found.
139
+ * Shared instructions for the LLM on how to use the tools within this toolkit.
140
+ * These instructions are intended to be added to the system prompt if `addInstructions` is true.
141
+ * Optional.
138
142
  */
139
- removeToolkit(toolkitName: string): boolean;
143
+ readonly instructions?: string | undefined;
144
+ /**
145
+ * Whether to automatically add the toolkit's `instructions` to the agent's system prompt.
146
+ * If true, the instructions from individual tools within this toolkit might be ignored
147
+ * by the Agent's system message generation logic to avoid redundancy.
148
+ * Defaults to false.
149
+ */
150
+ readonly addInstructions: boolean;
151
+ /**
152
+ * Constructor does not accept toolkits - only tools
153
+ * */
154
+ constructor(name: string, items?: (AgentTool | Tool$1)[],
155
+ /**
156
+ * A brief description of what the toolkit does or what tools it contains.
157
+ * Optional.
158
+ */
159
+ description?: string | undefined,
160
+ /**
161
+ * Shared instructions for the LLM on how to use the tools within this toolkit.
162
+ * These instructions are intended to be added to the system prompt if `addInstructions` is true.
163
+ * Optional.
164
+ */
165
+ instructions?: string | undefined,
166
+ /**
167
+ * Whether to automatically add the toolkit's `instructions` to the agent's system prompt.
168
+ * If true, the instructions from individual tools within this toolkit might be ignored
169
+ * by the Agent's system message generation logic to avoid redundancy.
170
+ * Defaults to false.
171
+ */
172
+ addInstructions?: boolean, logger?: Logger);
173
+ /**
174
+ * Toolkits are not supported inside a ToolkitManager (toolkits contain tools only).
175
+ * Keep the same signature as BaseToolManager.addToolkit to preserve type compatibility,
176
+ * but implement as a no-op (or warn) so callers won't crash.
177
+ */
178
+ addToolkit(toolkit: Toolkit): boolean;
179
+ }
180
+
181
+ declare class ToolManager extends BaseToolManager<AgentTool | Tool$1 | Toolkit, ToolkitManager> {
182
+ /**
183
+ * Creates a new ToolManager.
184
+ * Accepts individual tools, provider-defined tools, and toolkits.
185
+ */
186
+ constructor(items?: (AgentTool | Tool$1 | Toolkit)[], logger?: Logger);
140
187
  /**
141
- * Combine static base tools with runtime tools (includes tools from toolkits).
188
+ * Add a toolkit to the manager.
189
+ * If a toolkit with the same name already exists, it will be replaced.
190
+ * Also checks if any tool within the toolkit conflicts with existing standalone tools or tools in other toolkits.
191
+ * @returns true if the toolkit was successfully added or replaced.
142
192
  */
143
- combineStaticAndRuntimeBaseTools(runtimeTools?: (BaseTool | Toolkit)[]): BaseTool[];
193
+ addToolkit(toolkit: Toolkit): boolean;
194
+ prepareToolsForExecution(createToolExecuteFunction: (tool: AgentTool) => (args: any, options?: ToolExecuteOptions) => Promise<any>): Record<string, any>;
144
195
  /**
145
196
  * Get agent's tools (including those in toolkits) for API exposure.
146
197
  */
147
198
  getToolsForApi(): ApiToolInfo[];
148
199
  }
149
200
 
201
+ /**
202
+ * Status of a tool at any given time
203
+ */
204
+ type ToolStatus = "idle" | "working" | "error" | "completed";
205
+ /**
206
+ * Tool status information
207
+ */
208
+ type ToolStatusInfo = {
209
+ name: string;
210
+ status: ToolStatus;
211
+ result?: any;
212
+ error?: any;
213
+ input?: any;
214
+ output?: any;
215
+ timestamp: Date;
216
+ parameters?: any;
217
+ };
218
+
150
219
  /**
151
220
  * Tool definition compatible with Vercel AI SDK
152
221
  */
@@ -184,7 +253,7 @@ type ToolOptions<T extends ToolSchema = ToolSchema, O extends ToolSchema | undef
184
253
  /**
185
254
  * Function to execute when the tool is called
186
255
  */
187
- execute?: (args: z.infer<T>, context?: OperationContext) => Promise<O extends ToolSchema ? z.infer<O> : unknown>;
256
+ execute?: (args: z.infer<T>, context?: OperationContext, options?: ToolExecuteOptions) => Promise<O extends ToolSchema ? z.infer<O> : unknown>;
188
257
  };
189
258
  /**
190
259
  * Tool class for defining tools that agents can use
@@ -218,7 +287,7 @@ declare class Tool<T extends ToolSchema = ToolSchema, O extends ToolSchema | und
218
287
  /**
219
288
  * Function to execute when the tool is called
220
289
  */
221
- readonly execute?: (args: z.infer<T>, context?: OperationContext) => Promise<O extends ToolSchema ? z.infer<O> : unknown>;
290
+ readonly execute?: (args: z.infer<T>, context?: OperationContext, options?: ToolExecuteOptions) => Promise<O extends ToolSchema ? z.infer<O> : unknown>;
222
291
  /**
223
292
  * Whether this tool should be executed on the client side.
224
293
  * Returns true when no server-side execute handler is provided.
@@ -416,24 +485,23 @@ type MessageRole = "user" | "assistant" | "system" | "tool";
416
485
  */
417
486
  type BaseMessage = ModelMessage;
418
487
  type ToolSchema = z.ZodType;
419
- type ToolExecuteOptions = {
488
+ type ToolExecuteOptions = ToolCallOptions & {
420
489
  /**
421
- * Optional AbortController for cancelling the execution and accessing the signal
490
+ * Optional AbortController for cancelling the execution and accessing the signal.
491
+ * Prefer using the provided abortSignal, but we keep this for backward compatibility.
422
492
  */
423
493
  abortController?: AbortController;
424
494
  /**
425
- * @deprecated Use abortController.signal instead. This field will be removed in a future version.
426
- * Optional AbortSignal to abort the execution
495
+ * @deprecated Use abortController.signal or options.abortSignal instead. This field will be removed in a future version.
427
496
  */
428
497
  signal?: AbortSignal;
429
498
  /**
430
499
  * The operation context associated with the agent invocation triggering this tool execution.
431
- * Provides access to operation-specific state like context.
432
- * The context includes a logger with full execution context (userId, conversationId, executionId).
500
+ * Provides access to operation-specific state like context and logging metadata.
433
501
  */
434
502
  operationContext?: OperationContext;
435
503
  /**
436
- * Additional options can be added in the future
504
+ * Additional options can be added in the future.
437
505
  */
438
506
  [key: string]: any;
439
507
  };
@@ -3390,6 +3458,7 @@ interface OnToolStartHookArgs {
3390
3458
  tool: AgentTool;
3391
3459
  context: OperationContext;
3392
3460
  args: any;
3461
+ options?: ToolExecuteOptions;
3393
3462
  }
3394
3463
  interface OnToolEndHookArgs {
3395
3464
  agent: Agent;
@@ -3399,6 +3468,7 @@ interface OnToolEndHookArgs {
3399
3468
  /** The error if the tool execution failed. */
3400
3469
  error: VoltAgentError | AbortError | undefined;
3401
3470
  context: OperationContext;
3471
+ options?: ToolExecuteOptions;
3402
3472
  }
3403
3473
  interface OnPrepareMessagesHookArgs {
3404
3474
  /** The messages that will be sent to the LLM (AI SDK UIMessage). */
@@ -4529,10 +4599,7 @@ declare class Agent {
4529
4599
  * Validate tool output against optional output schema.
4530
4600
  */
4531
4601
  private validateToolOutput;
4532
- /**
4533
- * Convert VoltAgent tools to AI SDK format with context injection
4534
- */
4535
- private convertTools;
4602
+ private createToolExecutionFactory;
4536
4603
  /**
4537
4604
  * Create step handler for memory and hooks
4538
4605
  */