Conversation
Upgrade Vercel AI SDK from 5.0.124 to 6.0.85 along with all 19 @ai-sdk/* provider packages and third-party providers. Key changes: - Migrate generateObject/streamObject to generateText/streamText + Output.object() - Make convertToModelMessages async (now returns Promise) - Rename ToolCallOptions to ToolExecutionOptions - Update LanguageModelUsage type (inputTokenDetails/outputTokenDetails) - Add specificationVersion: 'v3' to middleware - Rename provider tool factories (createProviderDefinedToolFactory -> createProviderToolFactory) - Handle finish reason 'unknown' -> 'other' in copilot SDK - Update Anthropic top_p/temperature mutual exclusivity behavior - Fix PromiseLike -> Promise.resolve() for result.text - Fix asSchema().jsonSchema now being async - Re-enable Claude reasoning variants via Kilo Gateway (effort-based)
ed4dc24 to
cdf1ffd
Compare
| })() | ||
|
|
||
| const toModelOutput = (output: unknown) => { | ||
| const toModelOutput = ({ output }: { output: unknown }) => { |
There was a problem hiding this comment.
WARNING: Potential runtime error when output is null
typeof null === "object", so the later if (typeof output === "object") branch will treat null as an object and then access outputObject.text/attachments, which would throw. Consider guarding with output && typeof output === "object" (or output !== null) before the object branch.
| } | ||
|
|
||
| const BUNDLED_PROVIDERS: Record<string, (options: any) => SDK> = { | ||
| const BUNDLED_PROVIDERS: Record<string, (options: any) => any> = { |
There was a problem hiding this comment.
SUGGESTION: Avoid widening BUNDLED_PROVIDERS return type to any
Changing Record<string, (options: any) => SDK> to any weakens type safety and can hide provider factory incompatibilities introduced by the AI SDK v6 upgrade. If possible, keep a concrete return type (e.g. SDK or the specific provider factory return types) and add narrow casts at the few incompatibility points instead of globally opting out.
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Other Observations (not in diff)Issues found in unchanged code that cannot receive inline comments:
Files Reviewed (7 files)
|
Summary
Upgrades the Vercel AI SDK from
5.0.124to6.0.85along with all 19@ai-sdk/*provider packages and third-party providers (@openrouter/ai-sdk-provider,ai-gateway-provider).Package Version Changes
ai5.0.1246.0.85@ai-sdk/provider2.0.13.0.8@ai-sdk/provider-utils3.0.204.0.15@ai-sdk/anthropic2.0.583.0.43@ai-sdk/openai2.0.893.0.28@ai-sdk/google2.0.523.0.29@openrouter/ai-sdk-provider1.5.42.2.3@ai-sdk/*Key Changes
generateObject/streamObject→generateText/streamText+Output.object()— deprecated APIs replaced inagent/agent.tsconvertToModelMessagesis now async — updatedmessage-v2.tsand all call sites (prompt.ts,compaction.ts)ToolCallOptions→ToolExecutionOptions— renamed inprompt.tsLanguageModelUsagetype updated — now hasinputTokenDetails/outputTokenDetailssub-objectsspecificationVersion: "v3"— added inllm.tscreateProviderDefinedToolFactory→createProviderToolFactoryin copilot SDK"unknown"→"other"— updated in copilot SDK finish reason mapperstop_p/temperaturemutual exclusivity — SDK now dropstop_pwhentemperatureis set (Anthropic API requirement)toModelOutputparameter wrapping — now receives{ output }instead of raw outputasSchema().jsonSchemais now async — addedawaitresult.textisPromiseLike— wrapped withPromise.resolve()for.catch()Copilot SDK Strategy
The custom copilot SDK (
provider/sdk/copilot/) continues to implementLanguageModelV2— the AI SDK v6 automatically adapts V2 models via its built-in compatibility layer. This avoids a risky migration of the V2→V3 provider internals while maintaining full functionality.Validation
devbranch