@@ -752,6 +752,17 @@ function applyPostPluginStreamWrappers(
|
752 | 752 | shouldPatchModel: isDeepSeekV4OpenAICompatibleModel, |
753 | 753 | }); |
754 | 754 | |
| 755 | +// MiMo reasoning models use the same DeepSeek-style reasoning_content wire |
| 756 | +// format. When MiMo is reached through an unowned proxy/custom provider |
| 757 | +// (e.g. `xiaomi-orbit` pointed at token-plan-*.xiaomimimo.com), the bundled |
| 758 | +// xiaomi plugin's wrapStreamFn does not fire, so apply the shared wrapper |
| 759 | +// here as a fallback so multi-turn tool calls succeed. |
| 760 | +ctx.agent.streamFn = createDeepSeekV4OpenAICompatibleThinkingWrapper({ |
| 761 | +baseStreamFn: ctx.agent.streamFn, |
| 762 | +thinkingLevel: ctx.thinkingLevel, |
| 763 | +shouldPatchModel: isMiMoReasoningOpenAICompatibleModel, |
| 764 | +}); |
| 765 | + |
755 | 766 | // Guard Google-family payloads against invalid negative thinking budgets |
756 | 767 | // emitted by upstream model-ID heuristics for Gemini 3.1 variants. |
757 | 768 | ctx.agent.streamFn = createGoogleThinkingPayloadWrapper(ctx.agent.streamFn, ctx.thinkingLevel); |
@@ -831,6 +842,22 @@ function isDeepSeekV4OpenAICompatibleModel(model: Parameters<StreamFn>[0]): bool
|
831 | 842 | ); |
832 | 843 | } |
833 | 844 | |
| 845 | +const MIMO_REASONING_OPENAI_COMPATIBLE_MODEL_IDS = new Set([ |
| 846 | +"mimo-v2-pro", |
| 847 | +"mimo-v2-omni", |
| 848 | +"mimo-v2.5", |
| 849 | +"mimo-v2.5-pro", |
| 850 | +]); |
| 851 | + |
| 852 | +function isMiMoReasoningOpenAICompatibleModel(model: Parameters<StreamFn>[0]): boolean { |
| 853 | +const normalizedModelId = normalizeDeepSeekV4CandidateId(model.id); |
| 854 | +return ( |
| 855 | +model.api === "openai-completions" && |
| 856 | +normalizedModelId !== undefined && |
| 857 | +MIMO_REASONING_OPENAI_COMPATIBLE_MODEL_IDS.has(normalizedModelId) |
| 858 | +); |
| 859 | +} |
| 860 | + |
834 | 861 | /** |
835 | 862 | * Apply extra params (like temperature) to an agent's streamFn. |
836 | 863 | * Also applies verified provider-specific request wrappers, such as OpenRouter attribution. |
|