fix(cache): preserve client cache_control for Xiaomi MiMo (#3088) - #3093
Conversation
Add xiaomi-mimo to the prompt-caching provider allowlist so Claude Code (via cc-switch) cache_control breakpoints are preserved instead of stripped by the OpenAI-format translator. Restores cache hits that worked when calling Xiaomi directly.
There was a problem hiding this comment.
Code Review
This pull request adds the 'xiaomi-mimo' provider to the prompt-caching allowlist in open-sse/utils/cacheControlPolicy.ts to ensure client-side cache_control breakpoints are preserved and not stripped. It also includes corresponding unit tests in tests/unit/cache-control-policy.test.ts and updates the changelog. I have no feedback to provide as the changes are well-implemented and fully tested.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 576c9c5224
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // this entry, shouldPreserveCacheControl() returns false for Claude Code | ||
| // clients and filterToOpenAIFormat() strips cache_control, so Xiaomi never | ||
| // sees the cache hints and every request is a cache miss. | ||
| "xiaomi-mimo", |
There was a problem hiding this comment.
Preserve cache_control in the OpenAI translator too
When Xiaomi MiMo is targeted through the normal OpenAI-format path, this allowlist entry only makes shouldPreserveCacheControl() return true; translateRequest() still unconditionally calls filterToOpenAIFormat() for targetFormat === FORMATS.OPENAI, and that helper still removes cache_control from every content block. In the Claude Code/cc-switch → xiaomi-mimo scenario described here, the upstream payload therefore still loses the cache breakpoints, so the regression remains unfixed unless the OpenAI-format filter also honors preserveCacheControl.
Useful? React with 👍 / 👎.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge This is a clean, focused bug fix PR. It adds Files Reviewed (3 files)
Verification
No code quality issues, no security concerns, and no edge cases identified. The fix is minimal and well-targeted. Reviewed by laguna-m.1-20260312:free · 526,955 tokens |
…pw#3088) (diegosouzapw#3093) Add xiaomi-mimo to the prompt-caching provider allowlist so Claude Code (via cc-switch) cache_control breakpoints are preserved instead of stripped by the OpenAI-format translator. Restores cache hits that worked when calling Xiaomi directly.
…pw#3088) (diegosouzapw#3093) Add xiaomi-mimo to the prompt-caching provider allowlist so Claude Code (via cc-switch) cache_control breakpoints are preserved instead of stripped by the OpenAI-format translator. Restores cache hits that worked when calling Xiaomi directly.
…pw#3088) (diegosouzapw#3093) Add xiaomi-mimo to the prompt-caching provider allowlist so Claude Code (via cc-switch) cache_control breakpoints are preserved instead of stripped by the OpenAI-format translator. Restores cache hits that worked when calling Xiaomi directly.
Closes #3088
Problem
Xiaomi MiMo via cc-switch + OmniRoute showed zero cache hits, while calling Xiaomi directly cached normally.
Root cause
CACHING_PROVIDERSinopen-sse/utils/cacheControlPolicy.tsdid not includexiaomi-mimo. SoproviderSupportsCaching("xiaomi-mimo")returnedfalse→shouldPreserveCacheControl()returnedfalse→filterToOpenAIFormat()stripped everycache_controlblock before forwarding. Xiaomi's API therefore never saw the cache breakpoints and treated each request as a miss.Fix
Add
xiaomi-mimoto the prompt-caching provider allowlist (1 line). Now Claude Code'scache_controlhints are preserved for single-model routing.Tests
Added regression assertions to
tests/unit/cache-control-policy.test.ts:providerSupportsCaching("xiaomi-mimo")→ true (+ case-insensitive)shouldPreserveCacheControl({ userAgent: claude-cli, isCombo: false, targetProvider: "xiaomi-mimo" })→ truenode --import tsx/esm --test tests/unit/cache-control-policy.test.ts→ 37 pass / 0 fail. ESLint clean.