You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .changeset/voltagent-3-next.md
+69-18Lines changed: 69 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -151,7 +151,7 @@ const result = await agent.streamText({
151
151
152
152
VoltAgent composes the fields it must own for framework behavior: `model`, `prompt`/`messages`, `tools`, `abortSignal`, `maxRetries`, `onStepEnd`, `onEnd`/`onFinish`, and `onError`. User callbacks are still accepted at the top level and are invoked after VoltAgent memory, guardrails, hooks, tracing, and recovery handling.
153
153
154
-
Top-level AI SDK `runtimeContext`, `toolsContext`, `telemetry`, and `experimental_telemetry` are intentionally not exposed. Use `voltagent.context` for per-call application context, VoltAgent tool context/hooks for tool execution context, and VoltAgent observability/OpenTelemetry configuration for telemetry.
154
+
Top-level AI SDK `toolsContext` is passed through for native AI SDK tools that declare `contextSchema`. Top-level AI SDK `runtimeContext`, `telemetry`, and `experimental_telemetry` are intentionally not exposed. Use `voltagent.context` for per-call application context and VoltAgent observability/OpenTelemetry configuration for telemetry.
155
155
156
156
The same shape works for streaming:
157
157
@@ -178,10 +178,11 @@ for await (const part of result.stream) {
178
178
179
179
### Tool usage
180
180
181
-
VoltAgent now accepts AI SDK-style tool sets directly. The recommended custom tool API is `tool()` from `@voltagent/core`, extended with VoltAgent-specific metadata under the `voltagent` namespace.
181
+
VoltAgent now accepts AI SDK-style tool sets directly. Raw AI SDK tools are first-class, so the recommended custom tool API is `tool()` from `ai`. Add VoltAgent-specific metadata with `withVoltAgentMetadata` when you need hooks, tags, API metadata, or display metadata.
182
182
183
183
```ts
184
-
import { Agent, tool } from"@voltagent/core";
184
+
import { tool } from"ai";
185
+
import { Agent } from"@voltagent/core";
185
186
import { openai } from"@ai-sdk/openai";
186
187
import { z } from"zod";
187
188
@@ -202,25 +203,77 @@ const agent = new Agent({
202
203
});
203
204
```
204
205
205
-
VoltAgent-specific tool metadata is available through the `voltagent` namespace, so existing framework features can be used with AI SDK-style tools:
206
+
Native AI SDK tool options such as `contextSchema` work unchanged with call-level `toolsContext`:
206
207
207
208
```ts
208
-
const refundCustomer =tool({
209
-
description: "Refund a customer order",
210
-
inputSchema: z.object({
211
-
orderId: z.string(),
212
-
reason: z.string(),
209
+
const weather =tool({
210
+
description: "Get weather for a city",
211
+
inputSchema: z.object({ city: z.string() }),
212
+
contextSchema: z.object({
213
+
apiKey: z.string(),
214
+
defaultUnit: z.enum(["celsius", "fahrenheit"]),
213
215
}),
214
-
execute: async ({ orderId, reason }) => {
215
-
returnissueRefund(orderId, reason);
216
+
execute: async ({ city }, { context }) => {
217
+
returnfetchWeather(city, {
218
+
apiKey: context.apiKey,
219
+
unit: context.defaultUnit,
220
+
});
216
221
},
217
-
voltagent: {
218
-
name: "Refund Customer",
219
-
purpose: "Issue customer refunds",
222
+
});
223
+
224
+
awaitagent.generateText({
225
+
prompt: "What is the weather in San Francisco?",
226
+
tools: { weather },
227
+
toolsContext: {
228
+
weather: {
229
+
apiKey: process.env.WEATHER_API_KEY!,
230
+
defaultUnit: "fahrenheit",
231
+
},
220
232
},
221
233
});
222
234
```
223
235
236
+
VoltAgent-specific tool metadata is optional and stored out-of-band so it is not sent to the model provider:
Register the tool under the canonical name the model should call:
225
278
226
279
```ts
@@ -233,11 +286,9 @@ const agent = new Agent({
233
286
});
234
287
```
235
288
236
-
The ToolSet key remains the canonical `tool.name` used for tool calls, approval, routing, and telemetry correlation. `voltagent.name` is display metadata and is emitted as `tool.display_name` for Console and observability consumers.
237
-
238
-
VoltAgent `tool()` intentionally does not expose AI SDK `contextSchema`, `runtimeContext`, `toolsContext`, `telemetry`, or `experimental_telemetry`. Use `voltagent.context` on the agent call for per-request application context, `voltagent` tool hooks for VoltAgent lifecycle context, and VoltAgent observability/OpenTelemetry configuration for telemetry.
289
+
The ToolSet key remains the canonical `tool.name` used for tool calls, approval, routing, and telemetry correlation. VoltAgent metadata `name` is display metadata and is emitted as `tool.display_name` for Console and observability consumers.
239
290
240
-
`createTool` is now a legacy compatibility helper for existing class-style tools. New code should use `tool()`.
291
+
`tool()` from `@voltagent/core` remains available as a convenience wrapper when inline `voltagent` metadata is preferred. `createTool` is now a legacy compatibility helper for existing class-style tools.
0 commit comments