fix(kimi): resolve Kimi Code API 403 errors and User-Agent restrictions (#3549)

* fix(kimi): resolve Kimi Code API 403 errors and User-Agent restrictions

Kimi Code subscription keys require a whitelisted coding-agent User-Agent to avoid access_terminated_error 403s. This adds User-Agent probing and caching for Kimi Code endpoints.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(kimi): omit temperature for kimi-for-coding API calls

Kimi Code rejects any non-default temperature with HTTP 400, which broke deep research probes and low-temp LLM rounds.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
KYDNO
2026-06-15 02:56:54 -04:00
committed by GitHub
parent 674457384a
commit 955455b797
10 changed files with 289 additions and 9 deletions
+32
View File
@@ -0,0 +1,32 @@
"""Kimi Code host-allowlist behavior (follow-up to provider support).
Kimi Code (https://api.kimi.com/coding/v1) is a subscription, OpenAI-compatible
cloud API with native tool-calling. These tests pin the three host-list integrations:
- agent loop sends native tool schemas to Kimi Code (not fenced-block parsing),
- teacher escalation treats Kimi Code as SOTA (loop OFF, no added latency).
"""
from src import agent_loop, teacher_escalation
class TestAgentToolHosts:
def test_kimi_code_in_api_hosts(self):
assert "api.kimi.com" in agent_loop._API_HOSTS
def test_kimi_code_url_matches_api_host(self):
url = "https://api.kimi.com/coding/v1/chat/completions"
assert any(h in url for h in agent_loop._API_HOSTS)
def test_unknown_host_not_matched(self):
url = "https://example.invalid/v1/chat/completions"
assert not any(h in url for h in agent_loop._API_HOSTS)
class TestTeacherEscalationSota:
def test_kimi_code_is_sota_not_self_hosted(self):
assert teacher_escalation.is_self_hosted("https://api.kimi.com/coding/v1/chat/completions") is False
def test_known_cloud_still_sota(self):
assert teacher_escalation.is_self_hosted("https://api.openai.com/v1") is False
def test_local_endpoint_still_self_hosted(self):
assert teacher_escalation.is_self_hosted("http://localhost:8000/v1") is True