Skip to content

Commit d48e710

Browse files
committed
fix: type AI SDK tool metadata fields
1 parent c69ea48 commit d48e710

4 files changed

Lines changed: 21 additions & 0 deletions

File tree

packages/core/src/agent/agent.spec-d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ describe("Agent Type System", () => {
226226
inputSchema: z.object({ value: z.string() }),
227227
execute: async ({ value }) => ({ result: value }),
228228
voltagent: {
229+
name: "test_tool",
230+
purpose: "Exercise AI SDK tool metadata typing",
229231
tags: ["test"],
230232
},
231233
}),

packages/core/src/tool/ai-sdk-tool.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ const VOLTAGENT_RAW_AI_SDK_TOOL_SYMBOL = Symbol.for("@voltagent/core.tool.raw-ai
1010
const metadataStore = new WeakMap<object, VoltAgentToolMetadata>();
1111

1212
export type VoltAgentToolMetadata<INPUT = unknown, OUTPUT = unknown> = {
13+
/**
14+
* Optional VoltAgent-facing tool name for display or metadata consumers.
15+
*
16+
* When the tool is registered in an AI SDK ToolSet, the object key remains
17+
* the execution name used by the model and tool calls.
18+
*/
19+
name?: string;
20+
/**
21+
* Optional VoltAgent-facing purpose for display or metadata consumers.
22+
*/
23+
purpose?: string;
1324
/**
1425
* Optional user-defined tags for organizing or routing tools.
1526
*/

packages/core/src/tool/manager/index.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ describe("ToolManager", () => {
315315
inputSchema,
316316
execute,
317317
voltagent: {
318+
name: "weatherLookup",
319+
purpose: "Fetch weather observations",
318320
tags: ["weather"],
319321
needsApproval: true,
320322
hooks,
@@ -345,6 +347,8 @@ describe("ToolManager", () => {
345347
"get_weather",
346348
aiTool,
347349
expect.objectContaining({
350+
name: "weatherLookup",
351+
purpose: "Fetch weather observations",
348352
tags: ["weather"],
349353
needsApproval: true,
350354
hooks,

website/docs/agents/tools.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ const agent = new Agent({
5858
return { location, temperature: 22, conditions: "sunny" };
5959
},
6060
voltagent: {
61+
name: "getWeather",
62+
purpose: "Fetch current weather for a location",
6163
tags: ["weather", "external-api"],
6264
hooks: {
6365
onStart: ({ tool }) => {
@@ -77,6 +79,8 @@ Each AI SDK-style tool has:
7779
- **inputSchema**: Input schema defined with Zod
7880
- **execute**: Function that runs when the tool is called
7981
- **providerOptions** (optional): Provider-specific options for advanced features
82+
- **voltagent.name** (optional): VoltAgent-facing name for display or metadata consumers. The ToolSet key remains the execution name.
83+
- **voltagent.purpose** (optional): VoltAgent-facing purpose for display or metadata consumers.
8084
- **voltagent.tags** (optional): Optional user-defined tags for organizing or labeling tools.
8185
- **voltagent.hooks** (optional): VoltAgent lifecycle hooks for observing or post-processing tool execution.
8286
- **voltagent.needsApproval** (optional): Static approval metadata for existing VoltAgent approval or tool-policy flows. Prefer call-level `toolApproval` for new per-request approval flows.

0 commit comments

Comments
 (0)