Skip to content

feat: add MiniMax provider support#99

Closed
octo-patch wants to merge 1 commit intorohitg00:mainfrom
octo-patch:feature/add-minimax-provider
Closed

feat: add MiniMax provider support#99
octo-patch wants to merge 1 commit intorohitg00:mainfrom
octo-patch:feature/add-minimax-provider

Conversation

@octo-patch
Copy link
Copy Markdown

@octo-patch octo-patch commented Apr 7, 2026

Summary

This PR adds MiniMax as a new LLM provider for agentmemory, enabling memory compression and summarization using MiniMax models via the Anthropic-compatible API.

Changes

  • src/providers/minimax.ts — New MiniMaxProvider class implementing the MemoryProvider interface
  • src/types.ts — Added "minimax" to the ProviderType union
  • src/providers/index.ts — Registered MiniMax in the provider factory
  • src/config.ts — Added MINIMAX_API_KEY auto-detection and minimax to VALID_PROVIDERS
  • test/minimax-provider.test.ts — 10 unit tests covering instantiation, API calls, error handling, and model selection

Configuration

Set the following environment variables in ~/.agentmemory/.env:

MINIMAX_API_KEY=your-api-key
MINIMAX_MODEL=MiniMax-M2.7  # optional, default: MiniMax-M2.7

Supported Models

Model ID Description
MiniMax-M2.7 Peak Performance. Ultimate Value. (default)
MiniMax-M2.7-highspeed Same performance, faster and more agile

API Reference

Implementation Notes

MiniMax uses the Anthropic-compatible API (https://api.minimax.io/anthropic), consistent with how the existing AnthropicProvider works. The implementation reuses the already-installed @anthropic-ai/sdk with a custom baseURL, requiring no new dependencies.

The provider is automatically selected when MINIMAX_API_KEY is set (priority: Anthropic → MiniMax → Gemini → OpenRouter → Agent SDK). It also participates in the fallback chain via FALLBACK_PROVIDERS.

Summary by CodeRabbit

  • New Features

    • Added support for MiniMax provider integration, enabling users to configure and use MiniMax models (MiniMax-M2.7 and MiniMax-M2.7-highspeed) for compression and summarization tasks when the MiniMax API key is provided.
  • Tests

    • Added comprehensive test suite validating MiniMax provider functionality and configuration handling.

- Add MiniMaxProvider class implementing MemoryProvider interface using Anthropic-compatible API
- Add MINIMAX_API_KEY environment variable support with auto-detection
- Add MINIMAX_MODEL environment variable support (default: MiniMax-M2.7)
- Register minimax in ProviderType union and provider factory
- Add minimax to VALID_PROVIDERS for fallback chain support
- Add unit tests for MiniMaxProvider (10 tests)
- Supported models: MiniMax-M2.7 and MiniMax-M2.7-highspeed
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 7, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 16f32449-5b62-479c-91f6-51a28de7109b

📥 Commits

Reviewing files that changed from the base of the PR and between 8704131 and 478ef11.

📒 Files selected for processing (5)
  • src/config.ts
  • src/providers/index.ts
  • src/providers/minimax.ts
  • src/types.ts
  • test/minimax-provider.test.ts

📝 Walkthrough

Walkthrough

This pull request adds support for the MiniMax AI provider, an Anthropic-compatible service. Changes include environment-based provider detection in configuration, a new provider implementation using the Anthropic SDK, type definitions for the new provider, and comprehensive test coverage.

Changes

Cohort / File(s) Summary
Type System Updates
src/types.ts
Extended ProviderType union to include "minimax" as a valid provider discriminator.
Provider Registration & Detection
src/config.ts, src/providers/index.ts
Added MiniMax provider detection via MINIMAX_API_KEY environment variable; extended detectProvider to return minimax configuration; registered provider in VALID_PROVIDERS for fallback support; wired provider instantiation in the provider factory.
MiniMax Provider Implementation
src/providers/minimax.ts
New provider module implementing MemoryProvider interface; exports model constants (MINIMAX_MODELS, DEFAULT_MINIMAX_MODEL) and MiniMaxProvider class that delegates compress and summarize operations to the Anthropic SDK with configurable model selection and token limits.
Test Suite
test/minimax-provider.test.ts
Comprehensive test coverage validating provider instantiation, model constants, API request formatting, response parsing, error propagation, custom baseURL handling, and default endpoint configuration.

Sequence Diagram

sequenceDiagram
    participant App as Application
    participant Config as Config Detection
    participant Factory as Provider Factory
    participant MiniMax as MiniMaxProvider
    participant Anthropic as Anthropic SDK

    App->>Config: Initialize with env vars
    Config->>Config: Check MINIMAX_API_KEY
    Config->>Factory: Create provider (type: "minimax")
    Factory->>MiniMax: Construct(apiKey, model, maxTokens)
    MiniMax->>MiniMax: Initialize Anthropic client
    
    App->>MiniMax: compress(systemPrompt, userPrompt)
    MiniMax->>Anthropic: messages.create(model, max_tokens, system, messages)
    Anthropic-->>MiniMax: Response with content blocks
    MiniMax->>MiniMax: Extract text block
    MiniMax-->>App: Return compressed text
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A whisker-twitched innovation hops into place,
MiniMax joins the provider race with grace,
From config detection to Anthropic's embrace,
New models compress and summarize with pace! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main feature added: MiniMax provider support. It is clear, concise, and directly reflects the changeset's primary objective across all modified and new files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rohitg00
Copy link
Copy Markdown
Owner

rohitg00 commented Apr 9, 2026

Closing as superseded by #103 which includes the same MiniMax provider plus the Anthropic baseURL fix. Thank you for the contribution @octo-patch — your PR helped identify the need and informed the final implementation.

@rohitg00 rohitg00 closed this Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants