structuredOutput issue with Zod primitives
I have noticed an issue: calling an agent.generate in 0.20.X recently I have noticed that giving a
structuredOutput
schema
option which is a Zod primitive (for example: schema: z.string()
instead of schema: z.object({ text: z.string() })
. This breaks every time with a validation error for me.
String is an example, but it also has issues with number(), etc.6 Replies
Example unit test I would expect to pass:
But it yields the following error:
So: it generated
{ "name": "Vulcano" }
for some reason📝 Created GitHub issue: https://github.com/mastra-ai/mastra/issues/8804
GitHub
[DISCORD:1427287637508620298] structuredOutput issue with Zod primi...
This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1427287637508620298 I have noticed an issue: calling an agent.generate in 0.20.X recently I have noticed t...
Hi @Vulcano ! Checking with the team, but I believe the schema has to be defined as an object, not a primitive
ok, yeah, so the schema must be defined as an object. In our next release, your code will actually throw an error telling you you need to provide an object 😉
Alright great in that case ill update my code thanks!
With error are you guys planning runtime or also typing?
📝 Created GitHub issue: https://github.com/mastra-ai/mastra/issues/8866
GitHub
[DISCORD:1427287637508620298] structuredOutput issue with Zod primi...
This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1427287637508620298 I have noticed an issue: calling an agent.generate in 0.20.X recently I have noticed t...
For now it'll be runtime, but we'll look into adding typyng as well 😉