-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Description
Bug Description
When using @convex-dev/agent@0.3.2 with zod@3.25.76, any agent with tools fails to run with:
TypeError: Cannot read properties of undefined (reading '_zod')
Environment
@convex-dev/agent: 0.3.2zod: 3.25.76ai: 5.0.110@ai-sdk/provider-utils: 3.0.18convex: 1.29.3
Reproduction
- Create an agent with any tool using
createTool:
import { Agent, createTool } from "@convex-dev/agent";
import { z } from "zod";
const myTool = createTool({
description: "Test tool",
args: z.object({
input: z.string(),
}),
handler: async (ctx, args) => {
return "result";
},
});
export const myAgent = new Agent(components.agent, {
name: "Test Agent",
tools: { myTool },
// ...
});- Try to run the agent
- Error occurs during tool schema validation
Root Cause
The @ai-sdk/provider-utils package checks for Zod 4 schemas using:
function isZod4Schema(zodSchema) {
return "_zod" in zodSchema;
}However, the zodSchema parameter is undefined when it reaches this check, causing the error.
Expected Behavior
Agents with tools should work with Zod 3.25.76, which is listed as a supported peer dependency in @ai-sdk/provider-utils.
Workaround Attempted
- Tried
zod@3.22.4- bundling fails (missingzod/v4export) - Tried
zod@3.23.8- same_zoderror - Tried
@convex-dev/agent@0.5.0-alpha.1- same error - Tried
zod/v3import - Convex bundler doesn't resolve it correctly
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels