fix(ai-sdk): upgrade to zod v4 and pin ai to 7.0.41 - #506
Open
brianstrauch wants to merge 2 commits into
Open
Conversation
The ai-sdk sample fails on a fresh install. Its .npmrc sets package-lock=false, so `npm install` floats every dependency to the newest in-range version, which surfaces two independent regressions. Compile: typescript floats ^5.6.3 -> 5.9.3, and TS 5.9 exceeds the instantiation depth limit on zod 3's types via the AI SDK v7 `tool()` helper, producing TS2589 (or an out-of-memory crash in tsc before it can report the error). zod v4 resolves this; verified clean against both TS 5.7.3 and 5.9.3. Runtime: `ai` floats 7.0.36 -> 7.0.55, pulling @ai-sdk/provider-utils >= 5.0.15. That version added a module-scope `isNodeDefaultFetch(globalThis.fetch)` call that runs `Function.prototype.toString.call(fetch)`. Workflows are deterministic and have no `fetch`, so importing `ai` inside the sandbox throws "Function.prototype.toString requires that 'this' be a Function" and every workflow task fails. Pin `ai` to 7.0.41, the last release depending on provider-utils 5.0.14. The pin is a stopgap until the guard is fixed upstream. @ai-sdk/mcp still resolves a 5.0.23 copy into the tree, but it is never evaluated in the sandbox, so it does not need pinning. All five samples verified via both pnpm and a fresh npm install. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
patbeqo
approved these changes
Aug 6, 2026
chris-olszewski
approved these changes
Aug 6, 2026
moedash
reviewed
Aug 6, 2026
The previous lockfile update was generated against a drifted local state, which pulled unrelated `food-delivery` churn into the diff: new `vercel@29.4.0`, `ts-node@10.9.2(...typescript@4.9.5)`, and `postcss-load-config` snapshots. Regenerate from main's lockfile baseline with pnpm 10.27.0 so the diff covers only the ai-sdk importer: `ai` 7.0.36 -> 7.0.41, the matching `@ai-sdk/*` bumps, and the zod v3 -> v4 peer re-resolution. Verified with `pnpm install --frozen-lockfile` and `pnpm build` in ai-sdk. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
ai-sdksample fails on a fresh install. Its.npmrcsetspackage-lock=false, sonpm installfloats every dependency to the newest in-range version. That surfaces two independent regressions.Bug A — TS2589 at compile time
typescriptfloats^5.6.3→ 5.9.3, and TS 5.9 exceeds the instantiation depth limit on zod 3's types via the AI SDK v7tool()helper:Some users see an out-of-memory crash in
tscinstead — that's the same problem, just dying before it can report the error. It is not caused by theaiversion:Bug B — workflow tasks fail at runtime
Hidden behind Bug A; fixing zod alone exposes it.
aifloats 7.0.36 → 7.0.55, pulling@ai-sdk/provider-utils>= 5.0.15, which added an unguarded module-scope call:Workflows are deterministic and have no
fetch, so importingaiinside the sandbox throws at import time and every workflow task fails:Bisected to exactly
@ai-sdk/provider-utils@5.0.15, first pulled in byai@7.0.42.Fix
zod→^4.0.0(resolves Bug A)ai→ pinned7.0.41, the last release depending on provider-utils 5.0.14 (resolves Bug B)@ai-sdk/mcpstill resolves a 5.0.23 copy into the tree, but it is never evaluated in the sandbox, so it does not need pinning.Testing
All five samples (
haiku,tools,mcp,middleware,stream) pass against a local dev server, via both pnpm and a freshnpm install, with zero worker errors. Build verified clean on both TS 5.7.3 and TS 5.9.3.Follow-ups (not in this PR)
aipin is a stopgap. Bug B needs an upstream guard (typeof fetch !== 'function') in@ai-sdk/provider-utils; an issue forvercel/aiis drafted but not yet filed.package-lock=falseinai-sdk/.npmrcis the root enabler — npm users get none of the reproducibility the committedpnpm-lock.yamlprovides, so the sample can break again at any time from an unrelated upstream release.🤖 Generated with Claude Code