Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

refactor: complete AI SDK migration — all 26 providers + neutral message model + cache unification - #11329

Closed
hannesrudolph wants to merge 1 commit into
mainfrom
refactor/ai-sdk-full-migration
Closed

refactor: complete AI SDK migration — all 26 providers + neutral message model + cache unification#11329
hannesrudolph wants to merge 1 commit into
mainfrom
refactor/ai-sdk-full-migration

Conversation

@hannesrudolph

Copy link
Copy Markdown
Contributor

Summary

Complete AI SDK migration across the entire provider layer, replacing raw SDK usage, legacy base classes, Anthropic-shaped message types, per-provider format transforms, and per-provider caching logic with a unified AI SDK architecture.

Builds on: PR #11297 (provider removals)

Changes

Provider Migrations (Sessions 1-5)

All 26 remaining providers now use AI SDK:

ArchetypeProvidersPattern
1 — OpenAICompatibleHandlerlm-studio, requesty, qwen-code, lite-llm, roo, vercel-ai-gateway, native-ollama, minimaxExtend OpenAICompatibleHandler, ~60-150 lines each
2 — Dedicated SDKopenai (@ai-sdk/openai), openai-native, openai-codex, openrouter (@openrouter/ai-sdk-provider), anthropic (@ai-sdk/anthropic), anthropic-vertex (@ai-sdk/google-vertex/anthropic)Use provider-specific AI SDK packages with streamText/generateText
3 — Custom adaptervscode-lmCustom LanguageModelV3 adapter wrapping VS Code LM API

Neutral Message Model (Session 6)

Replaced Anthropic.Messages.MessageParam with provider-agnostic types across 48 production files:

  • New NeutralMessageParam, NeutralContentBlock, RooMessageMetadata types in apiMessages.ts
  • ApiHandler.createMessage() accepts NeutralMessageParam[] (not Anthropic types)
  • @anthropic-ai/sdk isolated to the Anthropic provider itself

Transformer & Cache Cleanup (Session 7)

  • Deleted 10 dead files (~1,219 lines): per-provider caching files, anthropic-filter.ts
  • Created unified caching.ts with shared applyCacheBreakpoints() / buildCachedSystemMessage()
  • Cleaned 41 test files of @anthropic-ai/sdk type imports
  • Transform directory: 15 files → 6 provider-agnostic utilities

Dead Code Deleted

CategoryFiles DeletedLines Removed
Legacy base classesbase-openai-compatible-provider.ts, router-provider.ts~347
Format transformsr1-format.ts, mistral-format.ts, openai-format.ts, minimax-format.ts, vscode-lm-format.ts~1,249
Per-provider cachingcaching/anthropic.ts, caching/gemini.ts, caching/vertex.ts, caching/vercel-ai-gateway.ts~167
Filteringanthropic-filter.ts~52
Total12 files~1,815 lines

New Dependencies

  • @ai-sdk/openai (^3.0.26)
  • @ai-sdk/anthropic (^3.0.38)
  • @ai-sdk/provider (^3.0.4)

Verification

  • TypeScript: All 14 packages pass check-types
  • Tests: 5,251 pass, 0 failures (4 skipped — pre-existing)
  • Lint: All packages clean

Known Residuals

  • converters.ts retains @anthropic-ai/sdk import for tool types (needs neutral tool type definitions)
  • ai-sdk.ts (583 lines) could be further decomposed once storage shifts to AI SDK ModelMessage format
  • ~30 test files use @anthropic-ai/sdk for structurally-compatible fixtures (zero breakage, cosmetic cleanup)

@dosubotdosubotBot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Feb 9, 2026
@ellipsis-dev

Copy link
Copy Markdown
Contributor

⚠️ This PR is too big for Ellipsis, but support for larger PRs is coming soon. If you want us to prioritize this feature, let us know at help@ellipsis.dev


Generated with ❤️ by ellipsis.dev

@ghost

ghost commented Feb 9, 2026

Copy link
Copy Markdown

RooviewerClockSee task

Reviewed 434a0c9 (1 new commit since last review). Both previously flagged issues remain unresolved. No new issues found.

  • Azure OpenAI missing api-version query parameter -- src/api/providers/openai.ts lines 84-93: The Azure OpenAI branch of createProvider() does not inject the mandatory api-version query parameter (the Azure AI Inference branch correctly does). This will cause HTTP 400 errors for Azure OpenAI users.
  • Encrypted reasoning helpers not wired into createMessage -- src/api/providers/openai-native.ts lines 413-416: stripPlainTextReasoningBlocks, collectEncryptedReasoningItems, and injectEncryptedReasoning are defined and tested but never called from createMessage. Standalone encrypted reasoning items from buildCleanConversationHistory are silently dropped by convertToAiSdkMessages, breaking multi-turn reasoning continuity for o-series models. Same pattern in openai-codex.ts.
Previous reviews

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

Comment threadsrc/api/providers/openai.ts
Base automatically changed from refactor/phase0-remove-low-usage-providers to mainFebruary 9, 2026 16:41
@hannesrudolph
hannesrudolph marked this pull request as draft February 9, 2026 16:54
@hannesrudolph
hannesrudolphforce-pushed the refactor/ai-sdk-full-migration branch from bc67511 to 2ee82c1CompareFebruary 9, 2026 20:45
Comment threadsrc/api/providers/openai-native.ts
@hannesrudolph
hannesrudolphforce-pushed the refactor/ai-sdk-full-migration branch 2 times, most recently from 0a7cf86 to 59c882eCompareFebruary 9, 2026 21:36
… model + cache unification
Migrate all 26 providers to AI SDK, replace Anthropic-shaped message types with
AI SDK types, eliminate legacy transforms, and unify cache control.
Provider Migrations:
- 8 providers → OpenAICompatibleHandler (Archetype 1)
- 6 providers → dedicated @ai-sdk/* packages (Archetype 2/3)
- 3 OpenAI providers → @ai-sdk/openai (Chat Completions + Responses API)
- 3 providers → @openrouter/ai-sdk-provider, @ai-sdk/anthropic, @ai-sdk/google-vertex/anthropic
- 1 provider → custom LanguageModelV3 adapter (VS Code LM)
Type System:
- Replace Anthropic.MessageParam with AI SDK types (ToolCallPart, ToolResultPart, ReasoningPart, etc.)
- tool_use → tool-call, tool_result → tool-result, thinking → reasoning
- id/name/input → toolCallId/toolName/input, tool_use_id → toolCallId
- Add migrateApiMessages() for backward-compatible api_conversation_history.json reading
- Define RooContentBlock, RooMessageParam, RooMessageMetadata, RedactedReasoningPart
Dead Code Removed:
- Legacy base classes: BaseOpenAiCompatibleProvider, RouterProvider
- Format transforms: r1-format, mistral-format, openai-format, minimax-format, vscode-lm-format
- Per-provider caching: caching/anthropic, caching/gemini, caching/vertex, caching/vercel-ai-gateway
- anthropic-filter.ts
New Dependencies: @ai-sdk/openai, @ai-sdk/anthropic, @ai-sdk/provider
New Shared Utility: src/api/transform/caching.ts (unified cache control)
@hannesrudolph
hannesrudolphforce-pushed the refactor/ai-sdk-full-migration branch from 59c882e to 434a0c9CompareFebruary 9, 2026 21:48
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

size:XXLThis PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@hannesrudolph