You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched existing issues and this hasn't been requested yet.
Problem or Motivation
Problem or Motivation
Following up on #1397 for the @ag-ui/mastra package specifically.
As of @ag-ui/mastra@1.1.4, its published package.json declares zod: "^3.25.76" as a dependency. Applications using Zod 4 therefore install a separate Zod 3 copy for the adapter.
This is becoming awkward when @ag-ui/mastra is used alongside libraries that require Zod 4. For example, @rekog/mcp-nest@2.x, a NestJS library for building MCP servers, declares zod: "^4.3.5" as a peer dependency. Downgrading the application's Zod version to 3.x causes npm dependency resolution to fail.
@mastra/client-js and @mastra/core already accept both Zod 3 and Zod 4 in their peer dependency ranges. It would be useful for the AG-UI Mastra adapter to support applications using Zod 4 as well.
Proposed Solution
Test @ag-ui/mastra against Zod 4 and update its dependency declaration to support Zod 4 if the adapter is compatible. If code changes are needed, it would be helpful to document what is required before the dependency range can be widened.
Could the related @ai-sdk/ui-utils dependency also be checked? An npm install with @ag-ui/mastra@1.1.4 can produce an ERESOLVE overriding peer dependency warning involving @mastra/client-js, @ai-sdk/ui-utils, and the nested Zod 3 copy. Updating the adapter's Zod range alone may not remove that warning.
Could the Zod 4 support here come "for free" by moving @ag-ui/mastra off @ai-sdk/ui-utils onto the current AI SDK?
(I asked my agent to do some summary thingies :) )
From what I can see on @ag-ui/mastra@1.1.4, the only thing pulling in @ai-sdk/ui-utils (and with it the pinned zod@^3.25.76) is a single import of a single function — parsePartialJson: import { parsePartialJson } from "@ai-sdk/ui-utils";
@ai-sdk/ui-utils is an AI SDK v4-era package that peers zod@^3.23.8, so an app on Zod 4 ends up with a second, nested Zod 3 copy — which is the ERESOLVE overriding peer dependency warning mentioned above.
The same parsePartialJson is exported by the current AI SDK (the ai package, and @ai-sdk/provider-utils), which @mastra/core already depends on and which accepts zod@^3.25.0 || ^4.0.0. The return shape looks identical, with one difference I want to confirm:
// @ai-sdk/ui-utils (v4): synchronous
parsePartialJson(text): { value; state }
// ai / @ai-sdk/provider-utils (current): async
parsePartialJson(text): Promise<{ value; state }>
So the questions:
Is parsePartialJson the only reason @ai-sdk/ui-utils is a dependency, or does the adapter use anything else from it?
Would replacing that import with the one from the AI SDK already in the tree (and await-ing it at the one call site) be enough to drop @ai-sdk/ui-utils entirely — and in doing so let the Zod range widen to ^3.25.0 || ^4.0.0 (matching @mastra/core and @mastra/client-js)?
If it's not that simple, what else is in the way? (e.g. the sync→async change rippling into a sync stream-transform path, or a behavioral difference in the newer parsePartialJson.)
Also, would making zod a peer dependency (as proposed in #2518) rather than a pinned dependency be preferred here, so the host app controls the Zod version regardless of this specific swap?
#3224 fixes this. It drops @ai-sdk/ui-utils (the source of the nested Zod 3 copy) by vendoring a synchronous parsePartialJson, the same way Mastra did in mastra-ai/mastra#27297, and widens the adapter's zod range to ^3.25.76 || ^4.0.0. In a consumer install with Zod 4, the adapter now resolves the app's own Zod.
Activity
NathanTarbert commentedon Oct 2, 2026
Hey @T0nete, thanks for opening the issue. I've added support for Zod 4 to the roadmap.
sander-su commentedon Oct 6, 2026
Could the Zod 4 support here come "for free" by moving @ag-ui/mastra off @ai-sdk/ui-utils onto the current AI SDK?
(I asked my agent to do some summary thingies :) )
From what I can see on @ag-ui/mastra@1.1.4, the only thing pulling in @ai-sdk/ui-utils (and with it the pinned zod@^3.25.76) is a single import of a single function — parsePartialJson:
import { parsePartialJson } from "@ai-sdk/ui-utils";@ai-sdk/ui-utils is an AI SDK v4-era package that peers zod@^3.23.8, so an app on Zod 4 ends up with a second, nested Zod 3 copy — which is the ERESOLVE overriding peer dependency warning mentioned above.
The same parsePartialJson is exported by the current AI SDK (the ai package, and @ai-sdk/provider-utils), which @mastra/core already depends on and which accepts zod@^3.25.0 || ^4.0.0. The return shape looks identical, with one difference I want to confirm:
So the questions:
Also, would making zod a peer dependency (as proposed in #2518) rather than a pinned dependency be preferred here, so the host app controls the Zod version regardless of this specific swap?
fix(mastra): support Zod 4 by dropping @ai-sdk/ui-utils (ag-ui-protoc…
fix(mastra): support Zod 4 by dropping @ai-sdk/ui-utils (ag-ui-protoc…
fix(mastra): support Zod 4 by dropping @ai-sdk/ui-utils (ag-ui-protoc…
fix(mastra): vendor parsePartialJson and drop @ai-sdk/ui-utils (ag-ui…
fix(mastra): vendor parsePartialJson and drop @ai-sdk/ui-utils (ag-ui…
sander-su commentedon Oct 27, 2026
#3224 fixes this. It drops
@ai-sdk/ui-utils(the source of the nested Zod 3 copy) by vendoring a synchronousparsePartialJson, the same way Mastra did in mastra-ai/mastra#27297, and widens the adapter'szodrange to^3.25.76 || ^4.0.0. In a consumer install with Zod 4, the adapter now resolves the app's own Zod.It supersedes #3007, which took the
ai@5route.