Skip to content

Commit 4292460

Browse files
authored
fix: resolve Zod v4 compatibility issue in delegate_task tool schema (#590)
1 parent 2b17553 commit 4292460

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

.changeset/khaki-islands-try.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
"@voltagent/core": patch
3+
---
4+
5+
fix: resolve Zod v4 compatibility issue in delegate_task tool schema
6+
7+
Fixed a compatibility issue where `z.record(z.unknown())` in the delegate_task tool's context parameter was causing JSON schema generation errors with Zod v4. Changed to `z.record(z.string(), z.any())` which works correctly with both Zod v3 and v4.
8+
9+
The error occurred when using the MCP server or other components that convert Zod schemas to JSON schemas:
10+
11+
```
12+
TypeError: Cannot read properties of undefined (reading '_zod')
13+
```
14+
15+
This fix ensures the delegate_task tool works seamlessly across all Zod versions supported by the framework (^3.25.0 || ^4.0.0).

packages/core/src/agent/subagent/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,10 @@ ${task}\n\nContext: ${safeStringify(contextObj, { indentation: 2 })}`;
705705
parameters: z.object({
706706
task: z.string().describe("The task to delegate"),
707707
targetAgents: z.array(z.string()).describe("List of agent names to delegate the task to"),
708-
context: z.record(z.unknown()).optional().describe("Additional context for the task"),
708+
context: z
709+
.record(z.string(), z.any())
710+
.optional()
711+
.describe("Additional context for the task"),
709712
}),
710713
execute: async ({ task, targetAgents, context = {} }, currentOperationContext) => {
711714
// Fall back to the original operation context if not available

0 commit comments

Comments
 (0)