Date: 2026-07-09
Branch / worktree: fix/jul9-ai-sdk-v7 at /Users/cjols/Code/agents/fix/jul9-ai-sdk-v7
Base: rethink (f1b64cc5)
Scope: Minimal mechanical port of the Agents monorepo from AI SDK v6 to v7. No PR opened.
Note: this monorepo root is the rethink tree (packages live at
packages/*), so this report is at the worktree root rather than a nestedrethink/directory.
| Package | Before | After |
|---|---|---|
ai |
^6.0.x |
^7.0.0 (resolved 7.0.18) |
@ai-sdk/react |
^3.0.204 |
^4.0.0 (resolved 4.0.19) |
@ai-sdk/openai |
^3.0.70 |
^4.0.0 (resolved 4.0.9) |
@ai-sdk/anthropic |
^3.0.83 |
^4.0.0 (resolved 4.0.10) |
@ai-sdk/google |
^3.0.81 |
^4.0.0 (resolved 4.0.10) |
@ai-sdk/provider |
^3.0.10 (where used) |
^4.0.0 |
Updated 54 package.json files (root, packages, examples, experimental, think-starters, agent-think, wip) plus pnpm-lock.yaml.
- Migrate AI SDK 6.x to 7.0
- GitHub release notes for
ai@7.0.0onvercel/ai - Installed package types in
node_modules/ai@7.0.18
Change: ai@7 + @ai-sdk/*@4
Resolution: Bulk version bumps + pnpm install.
Status: Done.
Change: Stop-condition helper renamed (stepCountIs remains a deprecated alias).
Resolution: Renamed imports/usages in Think, voice tests, ai-chat e2e, codemode e2e, examples.
Status: Done.
Change: streamText / generateText top-level prompt option renamed.
Resolution:
- Think’s internal
streamText({ instructions: turnSystem })updated. TurnConfig.instructionsis the preferred public name; deprecatedTurnConfig.systemremains as an alias.StepConfig.instructionsis the preferred per-step override name; AI SDK/Think still accept deprecatedStepConfig.system.TurnContext.systemand extension snapshots remainsystembecause they describe Think’s assembled prompt context rather than a direct AI SDK call option.
Status: Done for AI SDK call sites and aliasable Think config surfaces.
| v6 | v7 | Status |
|---|---|---|
onStepFinish |
onStepEnd (alias kept) |
Think exposes preferred onStepEnd; deprecated onStepFinish remains as subclass alias |
onFinish |
onEnd |
Used where telemetry integrations needed it |
experimental_onToolCallFinish |
onToolExecutionEnd |
Think wired to onToolExecutionEnd |
StreamTextOnStepFinishCallback |
GenerateTextOnStepFinishCallback |
Import updated |
StreamTextOnFinishCallback |
GenerateTextOnFinishCallback |
ai-chat import updated |
StreamTextOnToolCallFinishCallback |
OnToolExecutionEndCallback |
Import updated |
Status: Done.
Change (important): The tool-finish event is no longer { success, output, error, durationMs, stepNumber }. In v7:
durationMs→toolExecutionMs- success/error/output →
toolOutputdiscriminated union:{ type: 'tool-result', output }{ type: 'tool-error', error }
stepNumberis not present on this event
Resolution: Think’s onToolExecutionEnd adapter exposes v7-style toolOutput and toolExecutionMs, while keeping deprecated success / output / error / durationMs aliases. stepNumber remains present as undefined because v7 no longer supplies it.
Status: Done. Covered by Think hooks tests (all 894 workers tests pass).
| v6 | v7 | Resolution |
|---|---|---|
experimental_telemetry |
telemetry (alias kept) |
Think exposes telemetry; deprecated experimental_telemetry still aliases to it |
TelemetryOptions.metadata |
removed | Test integration no longer sets/reads metadata |
OpenTelemetry built into ai |
moved to @ai-sdk/otel |
Not integrated (no prior OTEL registration in this repo path) |
| Telemetry opt-in per call | opt-out once an integration is registered | No global registration added |
Status: Mechanical rename done. OTEL package not added (no prior usage to migrate).
Change: usage.reasoningTokens / usage.cachedInputTokens removed; use outputTokenDetails.reasoningTokens / inputTokenDetails.cacheReadTokens.
Resolution: Extension step-finish snapshot reads both shapes with fallbacks.
Status: Done.
Change: Type removed; replacement is generic ToolExecutionOptions<CONTEXT>.
Resolution:
- Tests cast
{} as ToolExecutionOptions<unknown> - Tool
executeoption objects now includecontext: {}where required
Status: Done for compile/tests.
Change: Tool.description may be string | ((options) => string).
Resolution: Normalize to string (or drop function form) in:
packages/agents/src/chat/client-tools.tspackages/agents/src/browser/tanstack-ai.tspackages/codemode/src/connectors/toolset.ts
Status: Done.
Change: Inferred return types of createReadTool etc. pull non-portable types from @ai-sdk/provider-utils@5 / @ai-sdk/provider@4.
Resolution: Explicit : Tool / : ToolSet return annotations on workspace/extension tool factories.
Status: Done (@cloudflare/think builds).
Change: AI SDK packages are ESM-only; Node 22+ required.
Resolution: Monorepo already "type": "module"; local Node is v24.15.0. No engines field change made.
Status: N/A / already compatible.
Change: StreamTextResult.fullStream renamed to stream (alias kept).
Resolution: Voice package source/docs/tests now use result.stream terminology. Historical changelog entries still mention fullStream.
Status: Done.
Change: Prefer top-level toUIMessageStream({ stream: result.stream, ... }).
Resolution: Think's AI SDK boundary now uses top-level toUIMessageStream({ stream: result.stream, ... }). Package-local StreamableResult.toUIMessageStream() remains as Think's abstraction/test seam.
Status: Done.
Change: { role: 'system' } inside messages/prompt requires allowSystemInMessages: true.
Resolution: Not changed. Think already puts system text in the top-level instructions/system path.
Status: Monitor if any consumer feeds system-role messages into streamText messages arrays.
Change: Top-level usage, toolCalls, content, etc. now accumulate across steps; final-step-only via finalStep.
Resolution: No code changes. Call sites that assumed final-step-only semantics may need audit.
Status: TODO / document for follow-up.
Change: Prefer file over legacy image / image-data / media / file-data content parts. AI SDK v7 docs show multimodal tool results as { type: "file", mediaType, data: { type: "data", data } }.
Resolution: Think workspace file replay now emits file parts for images and other inline files. Tests updated.
Status: Done for known image-data / file-data AI SDK tool-result output paths.
Change: workers-ai-provider@4.0.0 declares peers on ai@^7 and @ai-sdk/*@^4.
Resolution: Updated AI SDK v7 applications to workers-ai-provider@^4.0.0. The AI SDK v6 compatibility matrix repins Think to provider v3.
Status: Done.
- Some Think context vocabulary still uses
system.TurnConfig/StepConfignow preferinstructionswith deprecatedsystemaliases, butTurnContext.systemand extension snapshots still usesystemfor the assembled prompt context. onToolExecutionEndno longer providesstepNumber. Think setsstepNumber: undefinedinToolCallResultContext. If callers relied on it, restore via step tracking in Think (not guessed here).- Do not globally register
@ai-sdk/oteluntil product wants default-on telemetry. allowSystemInMessagespolicy if any persisted transcripts embed system roles.- Audit multi-step result consumers for final-step-only assumptions (
usage,toolCalls,files, …). - Audit remaining package-local
toUIMessageStreamabstractions before next AI SDK major; Think's direct AI SDK result call was migrated to the stateless helper. - Codemod
npx @ai-sdk/codemod v7was attempted but timed out; renames applied manually / partially by an interrupted run, then cleaned up.
agents,@cloudflare/ai-chat,@cloudflare/codemode,@cloudflare/shell,@cloudflare/think,@cloudflare/rethink,@cloudflare/voice— build OK (after portable return types).
| Package | Result |
|---|---|
@cloudflare/think test:workers |
894/894 passed |
agents test |
2230/2230 passed |
@cloudflare/codemode test |
all passed (unit + e2e suites) |
@cloudflare/ai-chat test |
728/728 passed |
pnpm run typecheckstill reports residual errors, primarily:create-thinknot built (packages/think/src/cli/*)- Unbuilt example/provider packages (
@cloudflare/worker-bundler, voice providers, etc.)
- No remaining AI-SDK-specific type errors under
packages/source (excluding unbuilt create-think CLI).
cd /Users/cjols/Code/agents/fix/jul9-ai-sdk-v7
pnpm install
pnpm --filter agents --filter @cloudflare/think --filter @cloudflare/ai-chat --filter @cloudflare/codemode run build
pnpm --filter @cloudflare/think run test:workers
pnpm run typecheckNo PR was opened, per task instructions.