Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions open-sse/services/reasoningCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ const REASONING_REPLAY_PROVIDERS = new Set([
"sambanova",
"fireworks",
"together",
// Xiaomi MiMo enforces the same "pass back reasoning_content on subsequent
// turns" contract as DeepSeek/Kimi-thinking. Without replay the upstream
// 400s with "Param Incorrect: The reasoning_content in the thinking mode
// must be passed back to the API."
"xiaomi-mimo",
]);

const REASONING_REPLAY_MODEL_PATTERNS = [
Expand All @@ -44,6 +49,9 @@ const REASONING_REPLAY_MODEL_PATTERNS = [
/qwq/i,
/qwen.*think/i,
/glm.*think/i,
// MiMo (Xiaomi) thinking models — defensive match if a wildcard route
// assigns a non-`xiaomi-mimo` provider ID to a mimo-* model alias.
/^mimo[-.]?v\d/i,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The regex for mimo models uses a start-of-string anchor (^), which is inconsistent with the other patterns in REASONING_REPLAY_MODEL_PATTERNS (such as deepseek-r1, qwq, or qwen.*think). If a model ID is prefixed (e.g., provider/mimo-v2.5), this pattern will fail to match. Removing the ^ anchor would maintain consistency with the existing patterns and improve robustness against prefixed model names.

Suggested change
/^mimo[-.]?v\d/i,
/mimo[-.]?v\d/i,

];

/**
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/reasoning-cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,20 @@ describe("Reasoning Replay Cache — Provider Detection", () => {
assert.equal(requiresReasoningReplay("glm", "glm-5-thinking"), true);
});

it("should detect xiaomi-mimo provider", () => {
// MiMo enforces reasoning_content echo on subsequent turns; without
// replay the upstream returns 400 "Param Incorrect: The reasoning_content
// in the thinking mode must be passed back to the API."
assert.equal(requiresReasoningReplay("xiaomi-mimo", "mimo-v2.5-pro"), true);
assert.equal(requiresReasoningReplay("XIAOMI-MIMO", "mimo-v2.5"), true);
});

it("should detect mimo-v* model pattern under any provider id", () => {
assert.equal(requiresReasoningReplay("unknown-provider", "mimo-v2.5-pro"), true);
assert.equal(requiresReasoningReplay("unknown-provider", "mimo-v3"), true);
assert.equal(requiresReasoningReplay("unknown-provider", "MimoV2.5-pro"), true);
});

it("should NOT detect a generic openai model", () => {
assert.equal(requiresReasoningReplay("openai", "gpt-4o"), false);
});
Expand Down