Skip to content

feat(provider): add minimax provider for MiniMax Token Plan models #125

Description

@ferminquant

Feature request: add minimax provider for MiniMax Token Plan models

Summary

Add a new clawpatch provider named minimax that calls the MiniMax
OpenAI-compatible chat completions endpoint directly via fetch(). This
unblocks clawpatch users with a MiniMax Token Plan (or any other
minimax/MiniMax deployment) when their default provider (codex) is
unavailable or rate-limited, or when they prefer to use minimax/MiniMax for
reviews.

Motivation

  • The current codex default requires a local Codex CLI. Users who do
    not have Codex installed or authenticated have to fall back to acpx
    (which routes through openclaw) or to one of the other local CLI
    providers.
  • MiniMax exposes an OpenAI-compatible chat completions API at
    https://api.minimax.io/v1/chat/completions with stable schema-enforced
    output via response_format.json_schema. This is a clean fit for
    clawpatch's per-call provider contract.
  • clawpatch today has 9 supported providers (codex, acpx, claude,
    cursor, grok, opencode, pi, mock, mock-fail). Adding
    minimax covers a different distribution and is a real maintenance
    burden shared with maintainers.

Proposed approach

Add a new minimax provider in src/provider.ts that:

  • Reads the API key from MINIMAX_API_KEY env var.
  • POSTs to ${MINIMAX_BASE_URL:-https://api.minimax.io/v1}/chat/completions
    with model, messages, and response_format: {type: "json_schema", ...}.
  • Selects model via --model <name> (default MiniMax-M3).
  • Honors CLAWPATCH_MINIMAX_TIMEOUT_MS and CLAWPATCH_PROVIDER_TIMEOUT_MS
    for the per-call timeout.
  • Surfaces MiniMax-specific failure messages for 401/403/429.
  • Falls back to grokEnvelopeText-style envelope probing if the response
    shape is non-standard.

A reference implementation is available on the fork at
ferminquant/clawpatch on branch feat/minimax-provider.

Configuration

Env var Required Default Purpose
MINIMAX_API_KEY yes Token Plan API key (sk-cp-…)
MINIMAX_BASE_URL no https://api.minimax.io/v1 Override the endpoint
MINIMAX_MODEL no MiniMax-M3 Default model
CLAWPATCH_MINIMAX_TIMEOUT_MS no 300000 Per-call timeout
CLAWPATCH_PROVIDER_TIMEOUT_MS no 300000 Fallback timeout

Endpoints

  • POST /chat/completions — review, fix, revalidate, map
  • GET /models — connectivity check (used by check())

Verification on the reference implementation

  • pnpm typecheck — clean
  • pnpm lint — clean (1 unused-param warning fixed by renaming to _root)
  • pnpm format:check — clean (after pnpm format)
  • pnpm test src/provider.test.ts — 146/146 passing (135 pre-existing + 11 new)
  • pnpm build — clean
  • Live test: providerByName("minimax").check(...) against the real
    /v1/models endpoint with a Token Plan key returns
    provider=minimax default-model=MiniMax-M3 base=https://api.minimax.io/v1
  • End-to-end review run against feat_library_d4f04bd776 (a real
    feature in ferminquant/budget) completed in 4m07s and produced 5
    schema-valid findings.

The full test suite has 19 pre-existing failures in src/workflow.test.ts
that are unrelated to this change (verified by stashing the changes and
re-running the same test).

Labels

  • enhancement — new feature
  • help wanted — community contribution welcome
  • impact:other — provider routing / model choice
  • merge-risk: 🚨 auth-provider — touches the auth/credentials surface
  • documentation — README provider list needs updating

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal priority bug or improvement with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:auth-providerThis issue is about auth, provider routing, model choice, or SecretRef resolution.issue-rating: 🌊 off-meta tidepoolIssue quality rating does not apply to this item.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions