Skip to content

chore: upgrade AI SDK v6 → v7 (chat)#1817

Open
sweetmantech wants to merge 1 commit into
testfrom
chore/ai-sdk-v7-upgrade
Open

chore: upgrade AI SDK v6 → v7 (chat)#1817
sweetmantech wants to merge 1 commit into
testfrom
chore/ai-sdk-v7-upgrade

Conversation

@sweetmantech

@sweetmantech sweetmantech commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Second real upgrade in the monorepo-wide AI SDK v6→v7 migration (chat#1816). Targets test per repo convention. This is the first PR that actually validates a v6→v7 bump in our stack (marketing was a dead-code removal).

What changed

  • ai 6.0.1657.0.2
  • @ai-sdk/react 3→4, @ai-sdk/{anthropic,google,openai} 3→4, @ai-sdk/gateway 3→4, @ai-sdk/mcp 0.0.112
  • zod floor ^3.25.0^3.25.76 (ai@7 peer range)

Codemod (mechanical)

npx @ai-sdk/codemod v7 handled: isToolOrDynamicToolUIPartisToolUIPart, experimental_generateImagegenerateImage, Experimental_GenerateImageResultGenerateImageResult, systeminstructions on core generate calls.

Manual fixes (codemod over-applied / v7 types tightened)

  • hooks/useVercelChat.ts — reverted to onFinish. The codemod's onFinishonEnd is for core streamText/generateText; @ai-sdk/react useChat still uses onFinish (verified against the installed UseChatOptions type).
  • lib/ai/generateText.ts + generateArray.ts — these wrap the SDK behind a local { system } API. Kept that external param, pass instructions: system to the SDK internally (minimal blast radius vs. renaming the wrapper's API + all callers).
  • lib/email/generateTxtFileEmail.ts — calls the local wrapper, so its arg goes back to system:.
  • extractSendEmailResults.test.ts — dropped content/createdAt from UIMessage fixtures (v7 UIMessage is parts-only).

Note: generateObject is retained — it's alive in ai@7.0.2 (verified; a validation hook flagged it as removed, which is a false positive).

Verification (local)

Check Result
@ai-sdk/codemod v7 ✅ 8 files, mechanical
tsc --noEmit ✅ clean
vitest run ✅ 22 files / 72 tests pass
next build ✅ webpack compiles; full page-data step needs Supabase/Twilio env (present on Vercel) — preview validates

Will preview-verify the streaming chat UI end-to-end once the Vercel deploy is up.

Tracking: chat#1816. Merge target test; sync testmain per repo flow on release.

🤖 Generated with Claude Code


Summary by cubic

Upgrade ai SDK to v7 and bump related @ai-sdk/* packages, updating call sites to the v7 API (instructions, isToolUIPart, generateImage, GenerateImageResult). Existing app wrappers stay the same, so callers still use system and useChat still uses onFinish.

  • Dependencies

    • ai 6.0.165 → ^7.0.2
    • @ai-sdk/react 3 → ^4.0.2
    • @ai-sdk/{anthropic,google,openai} 3 → ^4.0.0
    • @ai-sdk/gateway 3 → ^4.0.2
    • @ai-sdk/mcp 0.0.11^2.0.0
    • zod floor → ^3.25.76
  • Migration

    • Requires Node 22+ runtime.
    • No app-level API changes; existing calls using system continue to work.
    • Tests using UIMessage should use parts-only messages (remove content and createdAt).

Written for commit 2988842. Summary will update on new commits.

Review in cubic

Bump to the v7 line:
- ai 6.0.165 → 7.0.2
- @ai-sdk/react 3 → 4, @ai-sdk/{anthropic,google,openai} 3 → 4,
  @ai-sdk/gateway 3 → 4, @ai-sdk/mcp 0.0.11 → 2
- zod floor → ^3.25.76 (ai@7 peer range)

Codemod (`npx @ai-sdk/codemod v7`) handled the mechanical renames:
`isToolOrDynamicToolUIPart` → `isToolUIPart`, `experimental_generateImage`
→ `generateImage`, `Experimental_GenerateImageResult` → `GenerateImageResult`,
and `system` → `instructions` on core generate calls.

Manual fixes where the codemod over-applied or v7 types tightened:
- hooks/useVercelChat.ts: keep `onFinish` (the codemod's onFinish→onEnd is for
  core streamText/generateText; @ai-sdk/react useChat still uses onFinish).
- lib/ai/generateText.ts, generateArray.ts: these wrap the SDK behind a local
  `{ system }` API — kept that param, pass `instructions: system` to the SDK.
- lib/email/generateTxtFileEmail.ts: calls the local wrapper, so back to `system:`.
- extractSendEmailResults.test.ts: drop `content`/`createdAt` from UIMessage
  fixtures (v7 UIMessage is parts-only).

Verified: `tsc --noEmit` clean, 72/72 vitest pass, `next build` compiles (full
page-data step needs Supabase/Twilio env, present on Vercel — preview validates).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chat Ready Ready Preview Jun 25, 2026 11:12pm

Request Review

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@sweetmantech, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 44 minutes and 50 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 94c0856d-3206-49db-8184-9396f9fb06d3

📥 Commits

Reviewing files that changed from the base of the PR and between 134dc41 and 2988842.

⛔ Files ignored due to path filters (3)
  • lib/emails/__tests__/extractSendEmailResults.test.ts is excluded by !**/*.test.* and included by lib/**
  • package.json is excluded by none and included by none
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml and included by none
📒 Files selected for processing (6)
  • components/VercelChat/MessageParts.tsx
  • lib/ai/generateArray.ts
  • lib/ai/generateImage.ts
  • lib/ai/generateText.ts
  • lib/emails/extractSendEmailResults.ts
  • lib/generateAndProcessImage.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/ai-sdk-v7-upgrade

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 9 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Requires human review: Major version bump of core AI SDK v6→v7 with multi-file API changes; requires human review for runtime compatibility despite clean static checks.

Re-trigger cubic

@sweetmantech

Copy link
Copy Markdown
Collaborator Author

✅ Verification — all checks green under AI SDK v7

Commit 2988842b. Preview: https://chat-qsdw9asft-recoup.vercel.app

Check Result
tsc --noEmit (local) ✅ clean
vitest (local) ✅ 72/72
Run unit tests (CI) ✅ pass (55s)
Vercel – chat (full build, real env) ✅ Deployment completed
CodeRabbit / cubic ✅ / ✅

The full production build that can't complete locally (needs Supabase/Twilio env) passes on Vercel. This validates the first real v6→v7 upgrade in the monorepo (marketing was a removal).

Note on browser smoke: the chat streaming UI sits behind Privy auth; a full logged-in send/stream test needs an email OTP I can't receive, so I'm relying on the green CI + full-env Vercel build + bot reviews. Happy to walk through a manual streaming check together if you want eyes on the UI before merge.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2988842bae

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread package.json
"@ai-sdk/mcp": "^0.0.11",
"@ai-sdk/openai": "3.0.66",
"@ai-sdk/react": "3.0.167",
"@ai-sdk/anthropic": "^4.0.0",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Update CI to Node 22 with the SDK bump

The AI SDK v7 bump pulls packages that now declare engines: { node: '>=22' } in pnpm-lock.yaml (ai@7.0.2 and the upgraded @ai-sdk/* packages), but the test workflow still runs actions/setup-node with node-version: 20 at .github/workflows/test.yaml:25. Any PR/test run on that workflow now installs and executes these packages outside their supported runtime, so CI can fail or stop matching the runtime this dependency set requires; please update the workflow/package engines to Node 22 alongside the upgrade.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant