Skip to content

Conversation

@hannesrudolph
Copy link
Collaborator

@hannesrudolph hannesrudolph commented Feb 10, 2026

Summary

Migrates the MiniMax provider from raw @anthropic-ai/sdk usage to the AI SDK (@ai-sdk/anthropic with custom baseURL), following the Archetype 3 migration pattern established by the Anthropic handler.

Changes

  • Rewrite minimax.ts: Replace raw Anthropic SDK client with createAnthropic() + streamText() / generateText() and shared transform layer (convertToAiSdkMessages, processAiSdkStreamPart, handleAiSdkError)
  • BaseURL path fix: Resolve all URLs to end with /anthropic/v1 since @ai-sdk/anthropic appends /messages directly (not /v1/messages like the raw Anthropic SDK)
  • Thinking signature capture: Add lastThoughtSignature, getThoughtSignature(), and getRedactedThinkingBlocks() matching the anthropic.ts pattern — critical for MiniMax interleaved thinking round-trip
  • Prompt caching: Via providerOptions.anthropic.cacheControl (AI SDK native) instead of manual cache_control blocks
  • isAiSdkProvider(): Returns true for proper reasoning block preservation in conversation history
  • Preserve mergeEnvironmentDetailsForMiniMax: Applied before convertToAiSdkMessages() to maintain tool result merging behavior
  • Rewrite minimax.spec.ts: Full test rewrite with AI SDK mocks — 21/21 tests pass

Important

Migrates MiniMax provider to AI SDK, refactoring URL handling, message streaming, and error management, with updated tests.

  • Migration to AI SDK:
    • Replaces raw Anthropic SDK with AI SDK in minimax.ts using createAnthropic(), streamText(), and generateText().
    • Adjusts baseURL handling to append /anthropic/v1.
  • New Methods:
    • Adds getThoughtSignature() and getRedactedThinkingBlocks() for capturing and retrieving thought signatures and redacted thinking blocks.
    • Implements isAiSdkProvider() to return true.
  • Error Handling:
    • Utilizes handleAiSdkError() for error management.
  • Prompt Caching:
    • Uses AI SDK's native caching via providerOptions.anthropic.cacheControl.
  • Tests:
    • Updates minimax.spec.ts to mock AI SDK functions and verify new behavior.
    • Ensures all 21 tests pass with the new implementation.

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

- Rewrite minimax.ts from raw @anthropic-ai/sdk to @ai-sdk/anthropic
  with createAnthropic(), streamText(), generateText()
- Use shared transform layer (convertToAiSdkMessages, processAiSdkStreamPart,
  handleAiSdkError) for all message/stream/error handling
- Preserve base URL conversion logic (/v1 -> /anthropic/v1) with /v1
  suffix for correct @ai-sdk/anthropic path construction
- Add thinking signature capture (lastThoughtSignature,
  getThoughtSignature, getRedactedThinkingBlocks) matching anthropic.ts
  pattern for proper interleaved thinking round-trip
- Preserve mergeEnvironmentDetailsForMiniMax preprocessing
- Prompt caching via providerOptions.anthropic.cacheControl
- isAiSdkProvider() returns true
- Rewrite minimax.spec.ts with AI SDK mocks (21/21 tests pass)
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. Enhancement New feature or request labels Feb 10, 2026
@roomote
Copy link
Contributor

roomote bot commented Feb 10, 2026

Rooviewer Clock   See task

Both previously flagged issues have been addressed. No new issues found.

  • Missing convertToolsForOpenAI step (minimax.ts:80): Now calls this.convertToolsForOpenAI(metadata?.tools) before convertToolsForAiSdk(), matching the Anthropic handler pattern.
  • Tests only exercise legacy config path (minimax.ts): LegacyApiConfiguration type and getLegacyApiConfiguration() removed. Tests now pass minimaxApiKey/minimaxBaseUrl as top-level properties matching the production ProviderSettings shape.
Previous reviews

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

…yApiConfiguration

- Add convertToolsForOpenAI preprocessing before convertToolsForAiSdk
  to handle MCP tool detection and schema normalization
- Remove LegacyApiConfiguration type and getLegacyApiConfiguration()
- Read options directly from flat ProviderSettings shape
- Update tests to use real ProviderSettings instead of apiConfiguration
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Feb 10, 2026
@hannesrudolph hannesrudolph merged commit b6bf829 into main Feb 10, 2026
13 checks passed
@hannesrudolph hannesrudolph deleted the feat/minimax-ai-sdk-migration branch February 10, 2026 01:33
@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

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

None yet

Development

Successfully merging this pull request may close these issues.

2 participants