#Error with the zod schema

1 messages · Page 1 of 1 (latest)

lucid spade
keen nymphBOT
#

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 trigger ZodError at runtime.

How to fix (migrate to Zod)

  1. Install Zod:
npm install zod
  1. 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:

Was this helpful?

If this solution worked for you, please click on the appropriate option below to help us improve:

lucid spade
#

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

keen nymphBOT
#

Thank you for your feedback! Our team will provide additional assistance. 🔄

keen nymphBOT
lucid spade
#

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

stoic marsh
#

Both are on the latest CopilotKit.

lucid spade
#

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

lucid spade
#

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"