feat: update AI SDK to v7#1922
Draft
cjol wants to merge 2 commits into
Draft
Conversation
This PR updates the repo from AI SDK v6 to v7 across the published packages, examples, guides, experiments, and starters. It migrates the current implementations only: new optimisations or improvements made available by the v7 SDK are intentionally out of scope for this change. ## Why - Consumers need the Agents SDK packages to work with AI SDK v7 and the matching @ai-sdk/* package majors. - A version-only bump was not enough because v7 renamed prompt, stop-condition, lifecycle callback, telemetry, and tool execution APIs used throughout the repo. - We could have renamed the Think-facing API to match v7 directly, but that would add a second API migration on top of the dependency migration. This keeps Think's existing caller-facing names where practical and translates at the AI SDK boundary. - We could have adopted v7-only follow-up improvements like stateless UI message stream helpers, final-step result audits, or media part cleanup here, but those are behaviour and design choices rather than required compatibility fixes. ## Public API Surface | Symbol | Kind | Notes | | ------ | ---- | ----- | | package peer dependencies | Breaking | Published packages now require ai@7 and @ai-sdk/react@4 where applicable. | | @cloudflare/think TurnConfig.experimental_telemetry | Changed | Still accepted, but now typed against the v7 telemetry option. v6 metadata is no longer supported by AI SDK v7. | | @cloudflare/think TurnConfig.telemetry | Additive | Accepted as the v7 option name and forwarded ahead of experimental_telemetry when present. | | @cloudflare/think StepContext | Changed | Still exported under the same name, now derived from GenerateTextOnStepFinishCallback. | | @cloudflare/ai-chat AIChatAgent.onChatMessage | Changed | The onFinish callback type now uses GenerateTextOnFinishCallback. | - Think still exposes system, onStepFinish, and experimental_telemetry as current top-level API names where callers already use them. - Think adapts v7 onToolExecutionEnd events back into the existing ToolCallResultContext shape for afterToolCall hooks and extensions. - ToolCallResultContext.stepNumber is now undefined for tool completion callbacks because AI SDK v7 no longer provides that value on the tool execution end event. ## Code Changes - Dependency ranges move from ai@6 and @ai-sdk/*@3 to ai@7 and @ai-sdk/*@4 across packages, examples, experiments, starters, and the lockfile. - AI SDK call sites use v7 names: instructions instead of system, isStepCount instead of stepCountIs, telemetry instead of experimental_telemetry at the SDK boundary, and onStepEnd or onToolExecutionEnd instead of the old lifecycle callback names. - Think keeps its public turn configuration and hook names stable while translating them into v7 streamText options internally. - Tool schema adapters in agents, codemode, and browser tooling normalize function-valued tool descriptions because downstream connectors still expect string descriptions. - agent-think drops telemetry metadata and uses functionId because AI SDK v7 removed TelemetryOptions.metadata. - forever-chat uses includeRawChunks directly for raw OpenAI response chunk handling. ## Compatibility - Consumers of published packages must install ai@7 and @ai-sdk/*@4-compatible peers. - Code that passed TelemetryOptions.metadata through Think's experimental_telemetry must move that identity into supported v7 telemetry fields or an integration. - Code that relied on stepNumber inside Think tool completion callbacks should treat it as unavailable for v7-backed executions. - This change does not migrate callers to new v7 capabilities beyond what is needed to keep the current implementations working.
🦋 Changeset detectedLatest commit: e15610d The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Author
AI SDK v7 breaking changes encountered
|
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.
This PR updates the repo from AI SDK v6 to v7 across the published packages, examples, guides, experiments, and starters. It migrates the current implementations only: new optimisations or improvements made available by the v7 SDK are intentionally out of scope for this change.
Why
Public API Surface
Code Changes
Compatibility