Skip to content

fix(llm): scope prompt cache keys to Moonshot APIs#2535

Open
Sanjays2402 wants to merge 1 commit into
MoonshotAI:mainfrom
Sanjays2402:fix/third-party-prompt-cache-key
Open

fix(llm): scope prompt cache keys to Moonshot APIs#2535
Sanjays2402 wants to merge 1 commit into
MoonshotAI:mainfrom
Sanjays2402:fix/third-party-prompt-cache-key

Conversation

@Sanjays2402

@Sanjays2402 Sanjays2402 commented Jul 23, 2026

Copy link
Copy Markdown

Related Issue

Resolve #2534

Description

Third-party Kimi-compatible endpoints no longer receive Moonshot's prompt_cache_key parameter, while official Kimi and Moonshot APIs retain session caching.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked the related issue, if any.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have run make gen-changelog to update the changelog.
  • I have run make gen-docs to update the user documentation.

Open in Devin Review

Third-party Kimi-compatible endpoints can reject the Moonshot-specific prompt_cache_key parameter. Only attach session cache keys to known Moonshot API hosts and cover both custom and official endpoint behavior.
Copilot AI review requested due to automatic review settings July 23, 2026 01:14

@devin-ai-integration devin-ai-integration 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

Copilot AI 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.

Pull request overview

This PR fixes a compatibility regression for third-party Kimi-compatible endpoints by only sending Moonshot’s prompt_cache_key when the configured base_url points at official Kimi/Moonshot hosts, avoiding 400 “unsupported parameter” errors on providers like Nvidia NIM.

Changes:

  • Add allowlisted host detection for whether prompt_cache_key should be sent for kimi providers.
  • Update create_llm to include prompt_cache_key only for official Kimi/Moonshot endpoints.
  • Add tests covering both omission for third-party endpoints and retention for official endpoints.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/kimi_cli/llm.py Introduces host allowlist logic and gates prompt_cache_key injection accordingly.
tests/core/test_create_llm.py Adds regression tests ensuring third-party endpoints don’t receive prompt_cache_key while official endpoints still do.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/kimi_cli/llm.py
Comment on lines +328 to +329
def _supports_prompt_cache_key(base_url: str) -> bool:
return urlparse(base_url).hostname in MOONSHOT_API_HOSTS
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.

Model API error 400 Validation: Unsupported parameter(s): prompt_cache_key

2 participants