Skip to content

Upgrade monorepo from AI SDK v6 → v7 (api, open-agents, chat, marketing, tasks, bash) #1816

Description

@sweetmantech

Tracking issue for upgrading the monorepo from AI SDK v6 → v7 across every submodule that depends on it. AI SDK 7 shipped 2026-06 (blog, announce); we are currently all-v6 and nothing is broken — the deprecated v6 helpers keep working until v8, so there is no forced deadline. This issue coordinates the per-repo upgrade work and links out to the PR in each submodule.

Decision 2026-06-25 — marketing is removed from this migration (not upgraded). The PoC bump surfaced that marketing's AI SDK usage is entirely dead code: the hero chat demo was deleted in marketing#31, leaving lib/agent/* orphaned (imported by nothing), ai consumed only by that dead code, and @ai-sdk/react unused. YAGNI call (sweets): delete the dead code + drop the packages rather than upgrade them — which also kills the dependency-scan false positive that put marketing on this list. See marketing#33.

Goal

Every submodule that imports ai / @ai-sdk/* runs on v7 (ai@7, @ai-sdk/*@latest), builds clean (the gate), and passes its tests. Mechanical renames are applied via the official codemod; the one piece of genuine engineering is the agent context redesign in api and open-agents. Done means: all six repos bumped and green on their target branch, no remaining v6-only API calls, and the two deprecated stream-helper call sites either migrated or consciously left (they still work in v7).

Reference: v6→v7 migration guide · codemod npx @ai-sdk/codemod v7 · guided skill npx skills add vercel/ai --skill migrate-ai-sdk-v6-to-v7.

PRs (updated 2026-06-25)

PR Item Base State
marketing#33 marketing — remove dead AI SDK demo code + 8 orphaned deps (was: v7 bump) main ✅ merged 2026-06-25 — see Done
chat#1817 chat v7 bump test 🔄 open — all checks green (CI tests + full-env Vercel build); awaiting merge
api#716 api v7 bump + typed tool context test 🔄 open — all checks green (CI test/lint/format + Vercel build); awaiting merge
none yet open-agents v7 bump + context redesign main ⏳ not started

Merge sequencing — smallest blast radius first: chat → api → open-agents. (Dropped 2026-06-25, codebases no longer in use: bash, tasks. marketing was a dead-code removal, not an upgrade — see decision above.) api and open-agents are last because they carry the context-architecture work, not just a codemod pass. Rows get real PR links as each branch opens.

What shipped (context — current state, all v6)

Repo ai Surface Module/Zod readiness
api 6.0.190 Large — full custom agent harness (lib/agent/tools/*, workflow runners) "type": "module", Zod 4 ✅
open-agents 6.0.165 Largepackages/agent tool/agent harness + apps/web agent pkg "type": "module", Zod 4 ✅
chat 6.0.165 Medium — generateText/generateObject, @ai-sdk/react useChat no "type": "module", Zod 3 ⚠️
marketing 6.0.154 Removed from migration — the only AI SDK usage (lib/agent/* + ai/@ai-sdk/react) was dead code from the demo deleted in marketing#31. Deleted in marketing#33. n/a

All repos are Next 16 / Node 22 era, so v7's Node 22+ minimum is already met.

Done

  • marketing — removed dead AI SDK demo code + 8 orphaned deps (NOT upgraded). (marketing#33)
    ✅ Shipped 2026-06-25 (squash-merged to main, merge commit 15507a3, by sweetmantech).
    Deleted lib/agent/ (system-prompt.ts, tools/index.ts, tools/similar-artists.ts) and removed 8 orphaned packages — ai, @ai-sdk/react, streamdown, @streamdown/{cjk,code,math,mermaid}, use-stick-to-bottom, nanoid — all leftovers from the hero chat demo deleted in marketing#31. Kept zod (used by subscribe/book/valuation/lead routes + post-schema.ts). Net 296 deletions, 0 additions. The earlier scan flagged marketing for a v7 bump; in fact none of this code ran, so the YAGNI removal also kills that dependency-scan false positive.
    Verified: tsc --noEmit clean (no module-not-found from the deletions = proof they were unused), next build compiles + typechecks, 67/67 vitest pass, and Vercel preview green (full prerender, real env). Browser regression on the preview: valuation artist-search flow works end-to-end (live /api/spotify/search autocomplete → select → "Value my catalog" enables), zero console errors — nothing the removed packages touched broke. verification.

Open — next up (in merge order; pick from the top)

  • chat — v7 bump. (chat#1817 — open, all checks green, awaiting merge)
    • Shipped (pending merge): ai 6.0.165→7.0.2; @ai-sdk/react/anthropic/google/openai 3→4, gateway 3→4, @ai-sdk/mcp 0.0.11→2; zod floor →^3.25.76. Codemod handled the mechanical renames (isToolOrDynamicToolUIPartisToolUIPart, experimental_generateImagegenerateImage, systeminstructions). Manual fixes: kept useChat's onFinish (codemod wrongly applied the core onFinishonEnd to the hook — @ai-sdk/react keeps onFinish); kept the local generateText/generateArray { system } wrapper API and pass instructions: system inward; dropped content/createdAt from UIMessage test fixtures (v7 is parts-only). generateObject retained (alive in v7).
    • Verified: tsc clean, 72/72 vitest, CI unit tests green, full-env Vercel build green, CodeRabbit + cubic pass. verification.
    • Note: no system-in-messages[] rejection issue surfaced; chat's lone system: was the txt-email wrapper, handled above.
    • Done when: merged to test, then testmain per repo flow.

Open — the real work (do last; these are migrations, not codemod passes)

  • api — v7 bump + typed tool context. (api#716 — open, all checks green, awaiting merge)

    • Outcome — less scary than predicted: the agent harness survived v7 (ToolLoopAgent, the agent loop, context passthrough all still exist). It was a rename + typed-context migration, not a ground-up redesign, and not a Zod-duplication issue (a zod override tried during diagnosis was removed).
    • Build gotcha (will recur in open-agents — same gateway+Workflow stack): v7's @ai-sdk/gateway@4 pulls in @vercel/oidc, which does a runtime require('./get-vercel-oidc-token.js'). Turbopack refuses to bundle the dynamic require → switched to next build --webpack (matches chat/marketing); webpack then mis-resolved the internal require when bundled → added @vercel/oidc to serverExternalPackages + as a direct dep so Node loads it natively.
    • The real v7 change: v7 infers a tool's context as never unless declared, breaking both the tool() overloads (TS2769) and toolsContext. Fix: annotate every context-using tool's execute 2nd arg : ToolExecutionOptions<AgentContext>. v7 also split experimental_context into a per-tool-name toolsContext map ({ bash: ctx, glob: ctx, … }) — added lib/agent/tools/buildToolsContext.ts to fan the single AgentContext out per tool key; wired into runAgentStep + taskTool.
    • Also: usage token shape (nested inputTokenDetails/outputTokenDetails; addLanguageModelUsage codemod-doubling, ZERO_USAGE, recordCreditDeduction); GoogleProviderOptionsGoogleGenerativeAIProviderOptions; ToolLoopAgent 4th generic (RoutingDecision/ChatConfig); reverted codemod over-applications (local { system } wrappers, toolChain systeminstructions types, webFetch discriminant/param-default). Test fixtures aligned to v7, no weakened assertions.
    • Verified: source tsc --noEmit 0 errors, pnpm test 3676 passed / 659 files. (~199 pre-existing __tests__ type-debt errors in unrelated domains left untouched; all tests pass at runtime.)
    • Done when: CI + full-env Vercel preview green, then merged to testmain per repo flow.
  • open-agents — v7 bump + context redesign. (target main)

    • Why: Same shape as apipackages/agent/tools/* + subagents/* use experimental_context throughout (part of the 118-hit total above); apps/web/app/api/chat/_lib/request.ts too. Monorepo (packages/agent + apps/web), so bump the workspace catalog + both packages.
    • Fix: codemod across the workspace, bump ai/@ai-sdk/* in packages/agent and apps/web, manually rework context threading to v7 model, rerun the agent's own tests (packages/agent/tools/tools.test.ts).
    • Done when: workspace builds, packages/agent tests pass, an end-to-end agent run works on a preview deploy.

Architecture decisions

  • Codemod-first, then manual. Run npx @ai-sdk/codemod v7 per repo for the ~35 mechanical renames (systeminstructions, experimental_outputoutput, experimental_telemetrytelemetry, stepCountIsisStepCount, fullStreamstream, onFinishonEnd, usage.reasoningTokensusage.outputTokenDetails.reasoningTokens, GoogleGenerativeAI*Google*, experimental_contextcontext, …). Treat the codemod output as a draft — the context redesign in api/open-agents is hand-written.
  • Build is the gate. Per repo convention, pnpm build (and pnpm exec tsc --noEmit in api) is the pass/fail gate; vitest where it exists. v6→v7 is not runtime-breaking for the deprecated helpers, so green build + a preview smoke test is the bar.
  • No forced deadline. v6 helpers (toUIMessageStream*, toTextStreamResponse, pipe*) are @deprecated in v7 but functional until v8. We migrate deliberately, smallest-risk-first, not under time pressure.
  • One PR per submodule, own branch. Each repo is an independent git repo; api/chat target test, the rest target main.

Accepted regressions / tradeoffs

  • The one remaining deprecated stream-helper call site — api/app/lib/workflows/runAgentStep.ts (toUIMessageStream) — may be left on the deprecated path initially to keep the v7 bump small; it works in v7 and only breaks in v8. Tracked here so it isn't forgotten before the v8 jump. (The marketing toUIMessageStreamResponse site noted in the original scan is gone — removed from main in marketing#31.)

Source references

  • AI SDK 7 blog · v6→v7 migration guide · v7 tracking issue vercel/ai#14011
  • Codemod: npx @ai-sdk/codemod v7 · guided skill: npx skills add vercel/ai --skill migrate-ai-sdk-v6-to-v7
  • Impact scan (2026-06-25): experimental_context = 118 hits / ~45 files across api + open-agents; deprecated stream helpers = 1 real call site on main (api runAgentStep.ts; the marketing site was already removed in marketing#31).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions