fix(agents): apply MiMo reasoning_content fallback wrapper for unowned proxy providers

This commit is contained in:
Jim Dawdy 2026-05-13 20:08:11 -05:00 committed by Peter Steinberger
parent 795ad845d6
commit aeb06bf4ef

View file

@ -752,6 +752,17 @@ function applyPostPluginStreamWrappers(
shouldPatchModel: isDeepSeekV4OpenAICompatibleModel,
});
// MiMo reasoning models use the same DeepSeek-style reasoning_content wire
// format. When MiMo is reached through an unowned proxy/custom provider
// (e.g. `xiaomi-orbit` pointed at token-plan-*.xiaomimimo.com), the bundled
// xiaomi plugin's wrapStreamFn does not fire, so apply the shared wrapper
// here as a fallback so multi-turn tool calls succeed.
ctx.agent.streamFn = createDeepSeekV4OpenAICompatibleThinkingWrapper({
baseStreamFn: ctx.agent.streamFn,
thinkingLevel: ctx.thinkingLevel,
shouldPatchModel: isMiMoReasoningOpenAICompatibleModel,
});
// Guard Google-family payloads against invalid negative thinking budgets
// emitted by upstream model-ID heuristics for Gemini 3.1 variants.
ctx.agent.streamFn = createGoogleThinkingPayloadWrapper(ctx.agent.streamFn, ctx.thinkingLevel);
@ -831,6 +842,22 @@ function isDeepSeekV4OpenAICompatibleModel(model: Parameters<StreamFn>[0]): bool
);
}
const MIMO_REASONING_OPENAI_COMPATIBLE_MODEL_IDS = new Set([
"mimo-v2-pro",
"mimo-v2-omni",
"mimo-v2.5",
"mimo-v2.5-pro",
]);
function isMiMoReasoningOpenAICompatibleModel(model: Parameters<StreamFn>[0]): boolean {
const normalizedModelId = normalizeDeepSeekV4CandidateId(model.id);
return (
model.api === "openai-completions" &&
normalizedModelId !== undefined &&
MIMO_REASONING_OPENAI_COMPATIBLE_MODEL_IDS.has(normalizedModelId)
);
}
/**
* Apply extra params (like temperature) to an agent's streamFn.
* Also applies verified provider-specific request wrappers, such as OpenRouter attribution.