Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: add MiniMax as an AI-coach provider - #54

Merged
saksham2001 merged 2 commits into
saksham2001:mainfrom
rgvxsthi:feat/minimax-provider
Jul 8, 2026
Merged

saksham2001 merged 2 commits into
saksham2001:mainfrom
rgvxsthi:feat/minimax-provider

Conversation

@rgvxsthi

@rgvxsthi rgvxsthi commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

What this does

Adds MiniMax as an AI-coach provider, alongside OpenAI, Gemini, and OpenRouter. It slots into the same provider-agnostic pattern already in the codebase (ResponsesClient + a per-provider Keychain store + the CoachClientResolver switch), so the rest of the coach is unchanged.

How it works

MiniMax speaks the OpenAI Chat Completions API, while this app speaks the OpenAI Responses API, so (exactly like OpenRouterClient / GeminiClient) the new MiniMaxClient is a translating adapter rather than a base-URL swap. It:

  • maps the app's flat Responses function tools to Chat Completions' nested tools shape, and replays tool calls statefully across the agent loop (Chat Completions is stateless, so it accumulates messages per turn);
  • strips MiniMax's inline <think>…</think> reasoning blocks from assistant content so the coach_response JSON parses cleanly;
  • deliberately sends no response_format, cache_control, reasoning, or provider-routing block — none are documented for MiniMax's compat endpoint. Output shape is enforced by the injected promptInstruction system message plus the orchestrator's existing JSON-repair loop (same fallback path OpenRouter uses).

Endpoint: POST https://api.minimax.io/v1/chat/completions, Authorization: Bearer <key>.

Model selection (Settings)

When MiniMax is the active provider, the Model row shows the current MiniMax catalog (default MiniMax-M3; also M2.7 / M2.5 / M2.1 and their -highspeed variants, plus M2). The key is stored in its own Keychain service.

Web search

MiniMax's compat endpoint exposes no hosted web search (its web_search is an MCP-only tool that an iOS app can't call over plain HTTP). So the Web search toggle is hidden when MiniMax is active (and forced off on switch), and the hosted web_search spec is dropped in the adapter. All other tools (retrieval, charts, analysis, memory, actions) work normally.

Image input

Only MiniMax-M3 is multimodal, so the "Image input" toggle is shown only when M3 is selected and force-cleared if you switch to a text-only model.

Scope / wiring

  • New: Coach/MiniMax/MiniMaxClient.swift, Coach/MiniMax/MiniMaxKeychainStore.swift
  • Wired .userMiniMaxKey through CoachProviderMode, MiniMaxModel presets, CoachFeatureFlags (gate + status line), the three resolveClient sites (chat / summaries / notifications), SettingsView.coachTrailing, and CoachSettingsSection (provider option, model picker, key field).

Testing done

  • Builds clean on an iOS simulator (app + widgets).
  • New MiniMaxClientTests (6): endpoint/model, tool-call parsing, hosted web_search dropped, response_format/reasoning/provider omitted, <think> stripping, and the stateful continuation replay (assistant tool_calls message re-inserted before the tool result).
  • Full PulseLoopTests suite passes (275 tests); existing OpenRouter suite still green.

⚠️ Needs live verification (I don't have a MiniMax key)

Everything above is compile- and unit-tested, but the wire protocol was built from MiniMax's docs and not exercised against a real key. Please confirm on device with a MiniMax key:

  1. Auth — save a key; the coach Status should read Ready · MiniMax-M3. A 401 would mean a Bearer token alone isn't enough (e.g. a GroupId is required) — the docs say Bearer-only, but this is the first thing to check.
  2. Tools + JSON — ask a data question (e.g. "how did I sleep this week"). This exercises function tool calls and confirms the model returns valid coach_response JSON even though response_format is omitted (prompt-instruction + JSON-repair only). This is the main behavioral risk.
  3. No leaked reasoning — verify answers don't show raw <think>…</think> text.
  4. Summaries + a check-in notification generate correctly.

Region note: the client uses the global host api.minimax.io. China-region accounts use api.minimaxi.com — there's a code comment at the endpoint marking where to flip it.

MiniMax speaks the OpenAI-compatible Chat Completions API, so it slots into
the existing provider-agnostic pattern (ResponsesClient + a per-provider
Keychain store + the CoachClientResolver switch), same as OpenRouter/Gemini.

- New MiniMaxClient: translating adapter for POST /v1/chat/completions —
  flat->nested tool conversion, stateful tool-call replay, tool_calls parsing,
  and <think>-block stripping so coach_response JSON parses. Deliberately omits
  cache_control, response_format, the OpenAI reasoning object, and provider
  routing (none documented for MiniMax's compat endpoint); relies on the
  promptInstruction system message + the orchestrator's JSON-repair loop.
- New MiniMaxKeychainStore (separate service, coexists with other keys).
- Wired .userMiniMaxKey through CoachProviderMode, MiniMaxModel presets,
  CoachFeatureFlags gating + status line, the three resolveClient sites, and
  the Settings provider/model/key UI.
- MiniMax has no hosted web search, so the Web search toggle is hidden when
  MiniMax is active (and forced off on switch) — all other tool calls work.

Tests: MiniMaxClientTests (endpoint/model, tool_calls parse, web_search drop,
omits response_format/reasoning/provider, <think> stripping); OpenRouter
suite still green.
@rgvxsthi
rgvxsthi requested a review from saksham2001 as a code owner July 6, 2026 07:00
@saksham2001 saksham2001 linked an issue Jul 6, 2026 that may be closed by this pull request
@saksham2001

Copy link
Copy Markdown
Owner

I don't have any ways to check this either. Going to merge this and create an issue so that the user who requested can test and report after the Test Flight release.

@saksham2001
saksham2001 merged commit cda2e9c into saksham2001:main Jul 8, 2026
2 checks passed
@rgvxsthi
rgvxsthi deleted the feat/minimax-provider branch July 16, 2026 04:22
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.

[Feature]: Mini Man API Support

2 participants