fix(kimi): omit temperature entirely for Kimi/Moonshot models (#13157)
Kimi's gateway selects the correct temperature server-side based on the active mode (thinking -> 1.0, non-thinking -> 0.6). Sending any temperature value — even the previously "correct" one — conflicts with gateway-managed defaults. Replaces the old approach of forcing specific temperature values (0.6 for non-thinking, 1.0 for thinking) with an OMIT_TEMPERATURE sentinel that tells all call sites to strip the temperature key from API kwargs entirely. Changes: - agent/auxiliary_client.py: OMIT_TEMPERATURE sentinel, _is_kimi_model() prefix check (covers all kimi-* models), _fixed_temperature_for_model() returns sentinel for kimi models. _build_call_kwargs() strips temp. - run_agent.py: _build_api_kwargs, flush_memories, and summary generation paths all handle the sentinel by popping/omitting temperature. - trajectory_compressor.py: _effective_temperature_for_model returns None for kimi (sentinel mapped), direct client calls use kwargs dict to conditionally include temperature. - mini_swe_runner.py: same sentinel handling via wrapper function. - 6 test files updated: all 'forces temperature X' assertions replaced with 'temperature not in kwargs' assertions. Net: -76 lines (171 added, 247 removed). Inspired by PR #13137 (@kshitijk4poor).
This commit is contained in:
@@ -31,7 +31,8 @@ def test_import_loads_env_from_hermes_home(tmp_path, monkeypatch):
|
||||
assert os.getenv("OPENROUTER_API_KEY") == "from-hermes-home"
|
||||
|
||||
|
||||
def test_generate_summary_custom_client_forces_kimi_temperature():
|
||||
def test_generate_summary_kimi_omits_temperature():
|
||||
"""Kimi models should have temperature omitted — server manages it."""
|
||||
config = CompressionConfig(
|
||||
summarization_model="kimi-for-coding",
|
||||
temperature=0.3,
|
||||
@@ -51,10 +52,11 @@ def test_generate_summary_custom_client_forces_kimi_temperature():
|
||||
result = compressor._generate_summary("tool output", metrics)
|
||||
|
||||
assert result.startswith("[CONTEXT SUMMARY]:")
|
||||
assert compressor.client.chat.completions.create.call_args.kwargs["temperature"] == 0.6
|
||||
assert "temperature" not in compressor.client.chat.completions.create.call_args.kwargs
|
||||
|
||||
|
||||
def test_generate_summary_public_moonshot_kimi_k2_5_forces_temperature_1():
|
||||
def test_generate_summary_public_moonshot_kimi_k2_5_omits_temperature():
|
||||
"""kimi-k2.5 on the public Moonshot API should not get a forced temperature."""
|
||||
config = CompressionConfig(
|
||||
summarization_model="kimi-k2.5",
|
||||
base_url="https://api.moonshot.ai/v1",
|
||||
@@ -75,10 +77,11 @@ def test_generate_summary_public_moonshot_kimi_k2_5_forces_temperature_1():
|
||||
result = compressor._generate_summary("tool output", metrics)
|
||||
|
||||
assert result.startswith("[CONTEXT SUMMARY]:")
|
||||
assert compressor.client.chat.completions.create.call_args.kwargs["temperature"] == 1.0
|
||||
assert "temperature" not in compressor.client.chat.completions.create.call_args.kwargs
|
||||
|
||||
|
||||
def test_generate_summary_public_moonshot_cn_kimi_k2_5_forces_temperature_1():
|
||||
def test_generate_summary_public_moonshot_cn_kimi_k2_5_omits_temperature():
|
||||
"""kimi-k2.5 on api.moonshot.cn should not get a forced temperature."""
|
||||
config = CompressionConfig(
|
||||
summarization_model="kimi-k2.5",
|
||||
base_url="https://api.moonshot.cn/v1",
|
||||
@@ -99,7 +102,7 @@ def test_generate_summary_public_moonshot_cn_kimi_k2_5_forces_temperature_1():
|
||||
result = compressor._generate_summary("tool output", metrics)
|
||||
|
||||
assert result.startswith("[CONTEXT SUMMARY]:")
|
||||
assert compressor.client.chat.completions.create.call_args.kwargs["temperature"] == 1.0
|
||||
assert "temperature" not in compressor.client.chat.completions.create.call_args.kwargs
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user