Skip to content

Add Xiaomi MiMo provider support#87

Open
oldschoola wants to merge 1 commit into
krazyjakee:masterfrom
oldschoola:feat/xiaomi-mimo-support
Open

Add Xiaomi MiMo provider support#87
oldschoola wants to merge 1 commit into
krazyjakee:masterfrom
oldschoola:feat/xiaomi-mimo-support

Conversation

@oldschoola

Copy link
Copy Markdown
Contributor

Summary

Adds first-class Xiaomi MiMo support across the CLI, library, and Studio using Xiaomi's OpenAI-compatible /v1/chat/completions endpoint.

What changed

  • add Provider::Xiaomi / --provider xiaomi with aliases like mimo, xiaomimimo, and xiaomi-mimo
  • add a dedicated mogen-llm::xiaomi client with Xiaomi defaults (mimo-v2.5-pro, mimo-v2-flash, mimo-v2.5), Bearer auth via XIAOMI_API_KEY, Xiaomi-specific thinking mapping, and longer timeout headroom for reasoning-enabled requests
  • keep Xiaomi image-backed review/planner paths on the documented vision model in both CLI and Studio
  • wire Xiaomi into Studio settings, provider slots, pricing tables, timeout guidance, and wizard routing
  • document the provider in the README and CLI/Studio docs
  • add Xiaomi request-shape, pricing, timeout, and vision-routing tests
  • increase the Windows debug CLI entry stack so cargo run -p mogen -- ... stays usable with the larger command graph

Verification

  • cargo check
  • cargo test -p mogen-llm xiaomi
  • cargo test -p mogen-studio classify_timeout_uses_specific_headline_and_hint
  • cargo test -p mogen-studio xiaomi_image_calls_use_vision_model_before_planning
  • cargo test -p mogen-studio text_only_calls_keep_configured_model
  • cargo test -p mogen-studio wizard_image_calls_use_provider_vision_model
  • cargo test -p mogen-studio wizard_text_calls_keep_configured_model
  • cargo test -p mogen-studio xiaomi_pricing_matches_overseas_rates
  • cargo run -p mogen -- generate "a single small blue cube" --provider xiaomi --model mimo-v2-flash --thinking medium --dry-run --max-repair-iters 1

Post-Deploy Monitoring & Validation

No additional operational monitoring required — this is a local CLI/desktop provider integration with no server-side deployment surface.

@krazyjakee krazyjakee left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Add Xiaomi MiMo provider support

Verdict: solid, mergeable. One refactor worth doing first, plus a few minor notes. Branch builds clean; all tests pass locally (314 in mogen-llm, 332 in mogen-studio).

The integration is thorough and correct. Every dispatch site is covered consistently — Provider enum, LlmClient, error mapping, from_env, settings store, Studio ProviderSlot, pricing seed, CLI ProviderArg, MCP docs. No missing match arms, no unwrap/panic hazards in the new paths. xiaomi.rs faithfully follows the existing zai_chat/openai template.

Safety — good

  • API-key handling matches the other providers: from_env trims and rejects blank, Bearer auth via XIAOMI_API_KEY, errors map cleanly into the unified ProviderError.
  • Budget enforcement, bounded timeouts, and error-body parsing are all present.
  • The MOGEN_DEBUG_HTTP path prints only the response body (truncated, env-gated) — it does not log the request or the bearer token. No key leakage.

Alignment — excellent

  • Reuses established patterns: the f32-temperature shortest-decimal workaround, the deliberate seed-omission (Xiaomi's schema has no seed), OpenAI-compatible image_url content parts.
  • Vision content ordering (image-first, text-last) intentionally matches openai.rs rather than zai_chat.rs (text-first) — both are documented per-provider choices, so this is fine.
  • Thinking mapping (Low/Medium → disabled, High/XHigh → enabled with larger token cap + longer timeout) is a sensible fit for Xiaomi's binary CoT toggle.

Issues to address

1. (Main) Vision-model-swap logic is now duplicated in three places. The same Zai → ZAI_VISION, Xiaomi → XIAOMI_VISION mapping appears in:

  • app/util/llm.rs::apply_provider_vision_model_override
  • app/wizard/pipeline.rs::apply_vision_model_if_needed
  • commands/generate.rs (inline)

A fourth provider with a text/vision split means updating three call sites, and missing one silently routes an image to a text model (400 or worse). Recommend centralizing as Provider::vision_model_override(self) -> Option<&'static str> in provider.rs and having all three call it. (Moving the Z.ai swap before the planner pass is a genuine improvement, though — the planner now sees the image too.)

2. (Minor) Large bundled cargo fmt churn. Much of the 490 deletions is unrelated reformatting across provider.rs, error_class.rs, workers.rs, mcp.rs, etc. It inflates the diff and mixes concerns. Ideally formatting-only changes land in a separate commit/PR.

3. (Minor) The documented verification is misleading. cargo test -p mogen-llm xiaomi reports "7 filtered out" — the xiaomi.rs module unit tests are named generically (request_body_includes_system_message, …) so the xiaomi name-filter skips them; only the mock-server integration test matches. They do pass under --lib, but the listed command gives false confidence.

4. (Nit) Pricing precision unverifiable. 0.435 / 0.87 / 0.0036 is stamped as "overseas pay-as-you-go" with no source link. Harmless given the zero-cost fallback, but a doc URL would help future maintainers.

Worth calling out as correct

The Gemini pricing matchers were tightened to require a gemini prefix so mimo-v2.5-pro can't shadow into the Gemini 2.5-pro tier. Verified every real Gemini model ID in the tree starts with gemini-, so this behavioral change to existing pricing is safe and was the right call.

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