Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Jan 29, 2026

Summary

Migrates DeepSeek provider from OpenAI SDK to the dedicated @ai-sdk/deepseek package, achieving full feature parity with significant improvements. Also fixes tool streaming for all AI SDK providers.

Changes

DeepSeek Provider Migration

  • Before: 150 lines using OpenAI SDK directly
  • After: 181 lines using @ai-sdk/deepseek
  • Native reasoning support for deepseek-reasoner model
  • Cache metrics from providerMetadata.deepseek
  • Automatic consecutive message handling (no manual R1 format conversion)
  • Azure AI Inference support via custom baseURL
  • All 29 tests passing ✅

Tool Streaming Fixes (affects DeepSeek + Moonshot)

  • Added handleToolCallEvent() helper in Task.ts (DRY)
  • Added top-level handlers for tool_call_start/delta/end events
  • Fixed duplicate tool rendering by ignoring redundant tool-call events
  • Tools now display with real-time argument streaming (character-by-character)

Files Modified

  • src/api/providers/deepseek.ts - New AI SDK implementation
  • src/api/providers/__tests__/deepseek.spec.ts - Updated tests
  • src/core/task/Task.ts - Tool streaming event handlers
  • src/api/transform/ai-sdk.ts - Fixed duplication
  • src/package.json - Added @ai-sdk/deepseek dependency

Testing

  • ✅ 29/29 DeepSeek tests passing
  • ✅ All provider tests passing (5284 total)
  • ✅ Tool streaming verified working without duplicates
  • ✅ Reasoning content streaming working

Related Issues

Closes EXT-644


Important

Migrates DeepSeek to @ai-sdk/deepseek and fixes tool streaming for AI SDK providers, enhancing functionality and compatibility.

  • DeepSeek Provider Migration:
    • Migrated from OpenAI SDK to @ai-sdk/deepseek in deepseek.ts.
    • Added native reasoning support for deepseek-reasoner model.
    • Implemented cache metrics from providerMetadata.deepseek.
    • Enabled Azure AI Inference via custom baseURL.
    • All 29 tests in deepseek.spec.ts passing.
  • Tool Streaming Fixes:
    • Added handleToolCallEvent() in Task.ts for tool streaming events.
    • Implemented handlers for tool_call_start/delta/end events.
    • Ignored tool-call events to prevent duplicate tool rendering.
  • Miscellaneous:
    • Updated package.json to include @ai-sdk/deepseek dependency.
    • Modified ai-sdk.ts to process tool streaming events correctly.

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

@daniel-lxs daniel-lxs requested review from cte, jr and mrubens as code owners January 29, 2026 17:15
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. Enhancement New feature or request labels Jan 29, 2026
@roomote
Copy link
Contributor

roomote bot commented Jan 29, 2026

🤖 Roo Code Review

Review in progress. View Job

Summary

Status: ✅ Approved

This PR successfully migrates the DeepSeek provider from the OpenAI SDK to the dedicated @ai-sdk/deepseek package and fixes a duplicate tool rendering issue in AI SDK providers.

Key Changes Reviewed:

  1. DeepSeek Provider Migration (src/api/providers/deepseek.ts)

    • Clean implementation using @ai-sdk/deepseek package (v2.0.14)
    • Native reasoning support for deepseek-reasoner model
    • Cache metrics extraction from providerMetadata.deepseek (promptCacheHitTokens, promptCacheMissTokens)
    • Proper tool choice mapping with AI SDK format
  2. AI SDK Tool Streaming Fix (src/api/transform/ai-sdk.ts)

    • Fixed duplicate tool rendering by ignoring tool-call events
    • Uses tool-input-start/delta/end events for streaming tool calls
    • Well-documented with comments explaining the rationale
  3. DRY Refactoring (src/core/task/Task.ts)

    • Added handleToolCallEvent() helper method for reusable tool call handling
    • Direct case handlers for tool_call_start/delta/end events for AI SDK providers
    • Maintains backward compatibility with legacy tool_call_partial processing
  4. Test Coverage

    • Comprehensive tests for DeepSeek handler (39 tests)
    • AI SDK transform tests including tool-call ignore verification (13 tests)
    • Updated Moonshot tests to verify consistent behavior (19 tests)
    • All 71 tests pass

No Issues Found

The implementation is clean, well-tested, and follows established patterns in the codebase.


TODO

  • Initial review - no issues found (commit fd1fc0f)
  • Re-review after new commits - no issues found (commit 908677b)

Review run complete. View Job

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 29, 2026
- Migrate DeepSeek provider from OpenAI SDK to @ai-sdk/deepseek
- Add native reasoning support for deepseek-reasoner model
- Extract cache metrics from providerMetadata.deepseek
- Fix tool streaming for all AI SDK providers (DeepSeek, Moonshot)
- Add handleToolCallEvent() helper in Task.ts for DRY event handling
- Add top-level handlers for tool_call_start/delta/end events
- Fix duplicate tool rendering by ignoring redundant tool-call events
- Update all tests to use AI SDK mocks (29/29 passing)

Closes EXT-644
@daniel-lxs daniel-lxs force-pushed the feat/migrate-deepseek-to-ai-sdk branch from fd1fc0f to 908677b Compare January 29, 2026 20:44
Copy link
Contributor

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! This PR cleanly migrates DeepSeek to the dedicated @ai-sdk/deepseek package with native reasoning support and fixes the duplicate tool rendering issue in AI SDK providers. All 71 tests pass.

@daniel-lxs daniel-lxs merged commit 4b1d78f into main Jan 29, 2026
12 checks passed
@daniel-lxs daniel-lxs deleted the feat/migrate-deepseek-to-ai-sdk branch January 29, 2026 20:56
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Jan 29, 2026
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants