Skip to content

Conversation

@hannesrudolph
Copy link
Collaborator

@hannesrudolph hannesrudolph commented Feb 10, 2026

Summary

Migrates the Roo provider from the legacy BaseOpenAiCompatibleProvider (raw OpenAI SDK streaming) to AI SDK, completing the last production provider migration. Deletes the now-orphaned legacy base class.

Changes

  • src/api/providers/roo.ts — Full rewrite (435→327 lines):

    • Extends BaseProvider + SingleCompletionHandler (was BaseOpenAiCompatibleProvider)
    • Uses createOpenAICompatible() from @ai-sdk/openai-compatible + streamText/generateText from ai
    • Per-request provider factory (createRooProvider()) with fresh session token
    • Reasoning config sent via transformRequestBody callback
    • Custom headers (X-Roo-App-Version, X-Roo-Task-ID) via provider config
    • Protocol-aware token normalization (getApiProtocol) preserved
    • Server-side cost from providerMetadata.roo.cost with client-side fallback
    • isAiSdkProvider() returns true (critical for reasoning parts preservation)
    • generateImage() and dynamic model loading preserved unchanged
  • src/api/providers/__tests__/roo.spec.ts — Full test rewrite (45 tests):

    • Mocks ai and @ai-sdk/openai-compatible instead of openai
    • Tests reasoning config via transformRequestBody
    • Tests reasoning details accumulation, usage/cost, tool calls, headers
  • src/api/providers/base-openai-compatible-provider.ts — Deleted (legacy base class, 0 remaining consumers)

  • src/api/providers/__tests__/base-openai-compatible-provider.spec.ts — Deleted

  • src/api/providers/__tests__/base-openai-compatible-provider-timeout.spec.ts — Deleted


Important

Refactors RooHandler to use AI SDK, removing legacy base class and updating tests.

  • Behavior:
    • Migrates RooHandler in roo.ts from BaseOpenAiCompatibleProvider to AI SDK.
    • Uses createOpenAICompatible() and streamText/generateText for handling requests.
    • Adds createRooProvider() for per-request provider creation with session token.
    • Preserves generateImage() functionality.
  • Tests:
    • Rewrites roo.spec.ts to mock AI SDK instead of OpenAI.
    • Tests include reasoning config, tool calls, and headers.
  • Removals:
    • Deletes base-openai-compatible-provider.ts and its tests as they are no longer used.

This description was created by Ellipsis for bcd6298. You can customize this summary. It will automatically update as commits are pushed.

@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Feb 10, 2026
@roomote
Copy link
Contributor

roomote bot commented Feb 10, 2026

Rooviewer Clock   See task

No issues found. The latest commit adds stream-error resilience (matching the established consumeAiSdkStream pattern) and replaces the as any tool choice cast with the typed mapToolChoice utility. The previously flagged cost bug remains fixed.

  • roo.ts: calculateApiCostOpenAI receives already-normalized (non-cached) inputTokens for Anthropic-protocol models, causing cache tokens to be double-subtracted in the fallback cost calculation
Previous reviews

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

@hannesrudolph hannesrudolph changed the title refactor: migrate Roo provider to AI SDK refactor: Roogration - Migrate Roo provider to AI SDK Feb 10, 2026
Replace BaseOpenAiCompatibleProvider (raw OpenAI SDK) with AI SDK's
@ai-sdk/openai-compatible + streamText/generateText. Delete the legacy
base class now that its last consumer is migrated.

Key changes:
- RooHandler extends BaseProvider + SingleCompletionHandler
- Per-request provider factory with transformRequestBody for reasoning config
- Reasoning display via AI SDK's native reasoning-delta parts
- Protocol-aware usage normalization with server-side cost support
- isAiSdkProvider() returns true for reasoning parts preservation
- Delete BaseOpenAiCompatibleProvider (0 remaining consumers)
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Feb 10, 2026
@hannesrudolph hannesrudolph changed the title refactor: Roogration - Migrate Roo provider to AI SDK roofactor: Migrate Roo provider to AI SDK Feb 10, 2026
@hannesrudolph hannesrudolph merged commit 8d57da8 into main Feb 10, 2026
13 checks passed
@hannesrudolph hannesrudolph deleted the roogration-aisdk branch February 10, 2026 23:16
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants