Hi there I need a help with the new copilotkit update, in the frontend I'm receiving the same error mentioned in this github issue https://github.com/CopilotKit/CopilotKit/issues/2788 anyhelp please
#Error with the zod schema
1 messages · Page 1 of 1 (latest)
This solution has been AI generated
It looks like the new update introduced Zod-based parameter validation in the frontend. If your tools/hooks still use the old Parameter[] style or raw JSON Schema, you'll see Zod validation errors. Migrating parameters to Zod or converting your JSON Schema resolves this.
Why this happens
- v1.50 switched frontend hooks (e.g.,
useFrontendTool) to expect Zod schemas for parameters. - Pre-v1.50 code that passes
Parameter[]or JSON Schema can triggerZodErrorat runtime.
How to fix (migrate to Zod)
- Install Zod:
npm install zod
- Define parameters as a Zod schema and pass it to your hook:
import { z } from "zod";
const MyToolSchema = z.object({
input: z.string().describe("Input parameter description"),
});
useFrontendTool({
parameters: MyToolSchema,
// ...other options
});
If you have JSON Schema already
Convert it to Zod, then use the result:
import { convertJsonSchemaToZodSchema } from "@copilotkit/shared";
const jsonSchema = {
type: "object",
properties: {
field: { type: "string" },
},
required: ["field"],
};
const zodSchema = convertJsonSchemaToZodSchema(jsonSchema);
// Use `zodSchema` in your tool definitions
Extra checks
- Ensure all CopilotKit packages are updated to v1.50+.
- Clear build caches and rebuild.
- Start with a minimal Zod schema to isolate issues, then expand.
References:
- v1.50 notes: https://docs.copilotkit.ai/reference/whats-new/v1-50
- useFrontendTool: https://docs.copilotkit.ai/reference/hooks/useFrontendTool
- Schema conversion utility: https://github.com/CopilotKit/CopilotKit/tree/main/CopilotKit/packages/shared/src/utils/json-schema.ts
Was this helpful?
If this solution worked for you, please click on the appropriate option below to help us improve:
this happens when the data is being received by the frontend, means the tools are on the agent side and I wanna just render the result on my side not provide a frontend tools
Thank you for your feedback! Our team will provide additional assistance. 🔄
Hi @lucid spade, Could you share your code and let me know which framework and version you're using?
Also, check out the useRenderToolCall hook if you want to render backend tool calls in the frontend: https://docs.copilotkit.ai/reference/hooks/useRenderToolCall
The useRenderToolCall hook enables rendering of backend tool calls in the frontend.
well Im' using the latest nextjs version "next": "^16.0.10" well also for the copilotkit is the latest version as well "1.50.0" . I've tried all the hooks including the "useRenderToolCall" "useDefaultTool", those all takes the same logic as the useCopilotkitAction but I'm still receiving that annoying error.
Even in your examples all the versions are old there's no example having the new updated package
Hey @lucid spade, can you give these starters a look instead?
Both are on the latest CopilotKit.
well it won't work when you start your agent using the langgraph cli command "langgraph dev" instead of creating a manual starting endpoint in the agent side. I think that's the issue
the agent side is working just fine but in the client side I see always that issue I think I will downgrade to 1.10.6 that was working just fine, for your knowledge I'm starting my agent using the langgraph cli not using a custom startpoint file "using fastapi"