Skip to content

fix(cache): preserve client cache_control for Xiaomi MiMo (#3088) - #3093

Merged
diegosouzapw merged 1 commit into
release/v3.8.9from
fix/3088-xiaomi-cache
Jun 3, 2026
Merged

diegosouzapw merged 1 commit into
release/v3.8.9from
fix/3088-xiaomi-cache

Conversation

@diegosouzapw

Copy link
Copy Markdown
Owner

Closes #3088

Problem

Xiaomi MiMo via cc-switch + OmniRoute showed zero cache hits, while calling Xiaomi directly cached normally.

Root cause

CACHING_PROVIDERS in open-sse/utils/cacheControlPolicy.ts did not include xiaomi-mimo. So providerSupportsCaching("xiaomi-mimo") returned false → shouldPreserveCacheControl() returned false → filterToOpenAIFormat() stripped every cache_control block before forwarding. Xiaomi's API therefore never saw the cache breakpoints and treated each request as a miss.

Fix

Add xiaomi-mimo to the prompt-caching provider allowlist (1 line). Now Claude Code's cache_control hints 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" }) → true

node --import tsx/esm --test tests/unit/cache-control-policy.test.ts → 37 pass / 0 fail. ESLint clean.

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.
@diegosouzapw
diegosouzapw merged commit 28116c7 into release/v3.8.9 Jun 3, 2026
2 checks passed
@diegosouzapw
diegosouzapw deleted the fix/3088-xiaomi-cache branch June 3, 2026 09:55

@gemini-code-assist gemini-code-assist Bot left a comment

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.

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@kilo-code-bot

kilo-code-bot Bot commented Jun 3, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

This is a clean, focused bug fix PR. It adds xiaomi-mimo to the CACHING_PROVIDERS set in open-sse/utils/cacheControlPolicy.ts and includes appropriate test coverage.

Files Reviewed (3 files)

  • open-sse/utils/cacheControlPolicy.ts - Changes to CACHING_PROVIDERS constant
  • tests/unit/cache-control-policy.test.ts - Added test for xiaomi-mimo caching support
  • CHANGELOG.md - Updated with fix entry

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

HouMinXi pushed a commit to HouMinXi/OmniRoute that referenced this pull request Aug 2, 2026
…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.
Poid-ZA pushed a commit to Poid-ZA/OmniRoute that referenced this pull request Aug 5, 2026
…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.
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…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.
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.

1 participant