Skip to content

Prompt Caching Not Working for Xiaomi/MiMo Models #26460

Closed as not planned
Closed as not planned

Description

@xenstar

Description

Summary

When using OpenCode with Xiaomi's MiMo API directly, prompt caching (cache_control headers) is never applied, resulting in 0% cache hit rate and significantly higher token costs. In contrast, using the same models through OpenRouter achieves 90-95% cache hit rates because OpenRouter handles the caching headers correctly.

Root Cause: In opencode's source code (node-Bpcfl-9_.js:314466-314468), the applyCaching() function is only called for specific providers:

if ((model.providerID === "anthropic" ||
model.providerID === "google-vertex-anthropic" ||
model.api.id.includes("anthropic") ||
model.api.id.includes("claude") ||
model.id.includes("anthropic") ||
model.id.includes("claude") ||
model.api.npm === "@ai-sdk/anthropic" ||
model.api.npm === "@ai-sdk/alibaba") && ...)
MiMo uses @ai-sdk/openai-compatible which is NOT included in this condition.

The fix: opencode needs to add @ai-sdk/openai-compatible to the caching condition. This is a bug/missing feature in opencode.

Activity

  1. added
    needs:complianceThis means the issue will auto-close after 2 hours.
    and removed
    needs:complianceThis means the issue will auto-close after 2 hours.
    on May 9, 2026
  2. github-actions commented on May 9, 2026

    @github-actions
    Contributor

    Thanks for updating the issue! It now meets our contributing guidelines. We'll take a look.

  3. github-actions commented on Jul 9, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions