diff --git a/tests/run_agent/test_anthropic_prompt_cache_policy.py b/tests/run_agent/test_anthropic_prompt_cache_policy.py index ba6e54f0372..56e146d358c 100644 --- a/tests/run_agent/test_anthropic_prompt_cache_policy.py +++ b/tests/run_agent/test_anthropic_prompt_cache_policy.py @@ -75,6 +75,46 @@ class TestOpenRouter: assert agent._anthropic_prompt_cache_policy() == (False, False) +class TestKimiMoonshotOnOpenRouter: + """Kimi/Moonshot on OpenRouter honour envelope-layout cache_control (#25970).""" + + def test_kimi_k26_on_openrouter_caches_with_envelope_layout(self): + agent = _make_agent( + provider="openrouter", + base_url="https://openrouter.ai/api/v1", + api_mode="chat_completions", + model="moonshotai/kimi-k2.6", + ) + assert agent._anthropic_prompt_cache_policy() == (True, False) + + def test_moonshot_v1_on_openrouter_caches_with_envelope_layout(self): + agent = _make_agent( + provider="openrouter", + base_url="https://openrouter.ai/api/v1", + api_mode="chat_completions", + model="moonshotai/moonshot-v1-8k", + ) + assert agent._anthropic_prompt_cache_policy() == (True, False) + + def test_kimi_on_nous_portal_caches_with_envelope_layout(self): + agent = _make_agent( + provider="nous", + base_url="https://api.nousresearch.com/v1", + api_mode="chat_completions", + model="moonshotai/kimi-k2.6", + ) + assert agent._anthropic_prompt_cache_policy() == (True, False) + + def test_kimi_on_non_openrouter_host_does_not_cache(self): + agent = _make_agent( + provider="custom", + base_url="https://api.moonshot.cn/v1", + api_mode="chat_completions", + model="moonshotai/kimi-k2.6", + ) + assert agent._anthropic_prompt_cache_policy() == (False, False) + + class TestThirdPartyAnthropicGateway: """Third-party gateways speaking the Anthropic protocol (MiniMax, Zhipu GLM, LiteLLM)."""