Skip to content

feat(ai): MiniMax full-stack — embeddings compat shim, asymmetric type, chat touchpoint#2220

Open
tcflying wants to merge 7 commits into
garrytan:masterfrom
tcflying:fix/minimax-embeddings-shim
Open

feat(ai): MiniMax full-stack — embeddings compat shim, asymmetric type, chat touchpoint#2220
tcflying wants to merge 7 commits into
garrytan:masterfrom
tcflying:fix/minimax-embeddings-shim

Conversation

@tcflying

Copy link
Copy Markdown

Problem

The minimax recipe declared only an embedding touchpoint and was tagged
openai-compatible, but MiniMax's /v1/embeddings endpoint is not OpenAI-shaped
at the wire level — it requires {model, texts, type} and returns
{vectors, base_resp}. With no fetch shim, the AI SDK sent {input} and MiniMax
replied status_code 2013 "missing required parameter texts", surfacing as
[embed(minimax:embo-01)] Invalid JSON response and Embedded 0 chunks. MiniMax was
effectively unusable for embeddings, and there was no chat touchpoint at all.

Fix (3 commits)

  1. gateway.tsminimaxCompatFetch (mirrors voyageCompatFetch /
    zeroEntropyCompatFetch): OUTBOUND maps input → texts, derives type from the
    threaded input_type, strips OpenAI-only keys; INBOUND rewrites
    {vectors} → {data:[{embedding,index}]} and surfaces a non-zero
    base_resp.status_code as a thrown error (MiniMax returns HTTP 200 on logical
    errors). Wired into instantiateEmbedding's fetchWrapper dispatch for
    recipe.id === 'minimax'.
  2. dims.ts — asymmetric retrieval. embo-01 now emits input_type (same seam as
    ZE/Voyage) instead of a hardcoded type:'db', so embedQuery() threads 'query'
    and embed() threads 'document'; the shim maps that to MiniMax's type: db|query
    wire field.
  3. recipes/minimax.ts — chat touchpoint. MiniMax exposes an OpenAI-compatible
    /v1/chat/completions endpoint (same key); M3 function-calls and returns
    OpenAI-shaped responses (no shim needed). Adds MiniMax-M3 / MiniMax-M2.7
    (supports_tools, 800K ctx). With this plus the embedding fix, gbrain runs
    end-to-end — embed + search + graph + chat synthesis — on MiniMax alone, no
    OpenAI/Anthropic key required.

Testing

  • Verified end-to-end against the live API with a coding-plan key: embo-01 embeds
    (1536d), asymmetric db/query both succeed, gbrain think synthesizes from a
    brain page with a citation (Model: minimax:MiniMax-M3).
  • test/ai/recipe-minimax.test.ts updated for the new input_type behavior (document
    default + query path) and a new chat-touchpoint assertion.
  • Green locally: recipe-minimax, recipes-existing-regression, gateway,
    gateway-chat, dims-openai, dims-zeroentropy (89+ tests, 0 fail);
    bun run typecheck clean.

🤖 Generated with Claude Code

@tcflying

Copy link
Copy Markdown
Author

Added one more commit (fix(cli): windowsHide on the startup check-update spawn): the detached check-update --refresh-cache refresh had no windowsHide, so on Windows it flashed a console window / launch-error dialog. Same spawn-hygiene class. Happy to split into its own PR if you'd prefer it separate from the MiniMax work.

datoo added 7 commits June 19, 2026 19:43
…ata)

MiniMax /v1/embeddings is not OpenAI-shaped: it requires {model,texts,type}
and returns {vectors,base_resp}, but the minimax recipe was tagged
openai-compatible with no fetch shim, so embed sent {input} and got
status_code 2013, surfacing as 'Invalid JSON response' / 0 chunks embedded.

Adds minimaxCompatFetch (mirrors voyage/zeroentropy shims): maps input->texts,
derives type from threaded input_type (query|db), strips OpenAI-only keys,
rewrites {vectors} -> {data:[{embedding,index}]}, and surfaces a non-zero
base_resp.status_code as a thrown error. Verified end-to-end: embo-01 (1536d)
embeds + semantic query returns the expected page.
dims.ts hardcoded type:'db' for embo-01 (symmetric), with the asymmetric
seam deferred. Emit input_type instead so embedQuery threads 'query' and
embed threads 'document' through __embedInputTypeStore; minimaxCompatFetch
maps it to the wire type. Verified: doc embed (type:db) + query (type:query)
both succeed against embo-01, semantic recall intact.
…thesis on MMX

MiniMax exposes an OpenAI-compatible /v1/chat/completions endpoint (same
MINIMAX_API_KEY); M3 function-calls and returns OpenAI-shaped responses, so no
compat shim is needed. Adds a chat touchpoint (MiniMax-M3, MiniMax-M2.7;
supports_tools, 800K ctx, ~$0.58/$2.33 per 1M). With this + the embo-01
embedding fix, gbrain runs end-to-end (embed + search + graph + chat synthesis)
on MiniMax alone — no OpenAI/Anthropic key. Verified: gbrain think synthesizes
from a brain page with a citation, Model: minimax:MiniMax-M3.
… touchpoint

dimsProviderOptions now emits input_type (mapped to MiniMax's wire type by
minimaxCompatFetch) instead of the hardcoded type:'db'; assert the document
default + query path. Add coverage for the new chat touchpoint.
The detached `gbrain check-update --refresh-cache` refresh spawned on CLI
startup had no windowsHide, so on Windows it flashed a console window and could
surface a launch-error dialog (0x800700e8). Add windowsHide: true — it is a
best-effort background refresh, never user-facing.
propose_takes hardcoded 'claude-sonnet-4-6' for the budget pre-check estimate
AND the take_proposals.model_id audit column, while the actual gateway.chat call
uses the configured chat model. On a non-Anthropic setup (e.g. MiniMax) this
estimated cost at Sonnet rates (over-charging the budget → fewer pages scanned
per run) and mislabeled the audit. Add getChatModelSafe() (resolved chat model,
never-throws) and use it as the fallback so budget + label match the model
actually used. Verified: propose-takes + grade-takes + calibration tests pass,
typecheck clean.
Same fix as propose_takes: grade-takes (single-judge fallback) and
calibration-profile hardcoded 'claude-sonnet-4-6' for the judge/model label
while the real gateway.chat call uses the configured model. Use getChatModelSafe()
so non-Anthropic setups (MiniMax) record the model actually used. Tests pin the
default model explicitly (model: 'claude-sonnet-4-6') so they stay deterministic
regardless of gateway config. All cycle tests pass + typecheck clean.
@tcflying tcflying force-pushed the fix/minimax-embeddings-shim branch from 8693b83 to 4813e13 Compare June 19, 2026 11:43
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.

1 participant