mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
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:
parent
c1977146ce
commit
3cba81ebed
10 changed files with 170 additions and 246 deletions
|
|
@ -251,8 +251,12 @@ class TestBuildApiKwargsChatCompletionsServiceTier:
|
|||
assert "service_tier" not in kwargs
|
||||
|
||||
|
||||
class TestBuildApiKwargsKimiFixedTemperature:
|
||||
def test_kimi_for_coding_forces_temperature_on_main_chat_path(self, monkeypatch):
|
||||
class TestBuildApiKwargsKimiNoTemperatureOverride:
|
||||
def test_kimi_for_coding_omits_temperature(self, monkeypatch):
|
||||
"""Temperature should NOT be set client-side for Kimi models.
|
||||
|
||||
The Kimi gateway selects the correct temperature server-side.
|
||||
"""
|
||||
agent = _make_agent(
|
||||
monkeypatch,
|
||||
"kimi-coding",
|
||||
|
|
@ -261,7 +265,7 @@ class TestBuildApiKwargsKimiFixedTemperature:
|
|||
)
|
||||
messages = [{"role": "user", "content": "hi"}]
|
||||
kwargs = agent._build_api_kwargs(messages)
|
||||
assert kwargs["temperature"] == 0.6
|
||||
assert "temperature" not in kwargs
|
||||
|
||||
|
||||
class TestBuildApiKwargsAIGateway:
|
||||
|
|
|
|||
|
|
@ -918,7 +918,11 @@ class TestBuildApiKwargs:
|
|||
assert kwargs["messages"] is messages
|
||||
assert kwargs["timeout"] == 1800.0
|
||||
|
||||
def test_public_moonshot_kimi_k2_5_forces_temperature_1(self, agent):
|
||||
def test_public_moonshot_kimi_k2_5_omits_temperature(self, agent):
|
||||
"""Kimi models should NOT have client-side temperature overrides.
|
||||
|
||||
The Kimi gateway selects the correct temperature server-side.
|
||||
"""
|
||||
agent.base_url = "https://api.moonshot.ai/v1"
|
||||
agent._base_url_lower = agent.base_url.lower()
|
||||
agent.model = "kimi-k2.5"
|
||||
|
|
@ -926,9 +930,9 @@ class TestBuildApiKwargs:
|
|||
|
||||
kwargs = agent._build_api_kwargs(messages)
|
||||
|
||||
assert kwargs["temperature"] == 1.0
|
||||
assert "temperature" not in kwargs
|
||||
|
||||
def test_public_moonshot_cn_kimi_k2_5_forces_temperature_1(self, agent):
|
||||
def test_public_moonshot_cn_kimi_k2_5_omits_temperature(self, agent):
|
||||
agent.base_url = "https://api.moonshot.cn/v1"
|
||||
agent._base_url_lower = agent.base_url.lower()
|
||||
agent.model = "kimi-k2.5"
|
||||
|
|
@ -936,9 +940,9 @@ class TestBuildApiKwargs:
|
|||
|
||||
kwargs = agent._build_api_kwargs(messages)
|
||||
|
||||
assert kwargs["temperature"] == 1.0
|
||||
assert "temperature" not in kwargs
|
||||
|
||||
def test_kimi_coding_endpoint_keeps_kimi_k2_5_at_0_6(self, agent):
|
||||
def test_kimi_coding_endpoint_omits_temperature(self, agent):
|
||||
agent.base_url = "https://api.kimi.com/coding/v1"
|
||||
agent._base_url_lower = agent.base_url.lower()
|
||||
agent.model = "kimi-k2.5"
|
||||
|
|
@ -946,7 +950,7 @@ class TestBuildApiKwargs:
|
|||
|
||||
kwargs = agent._build_api_kwargs(messages)
|
||||
|
||||
assert kwargs["temperature"] == 0.6
|
||||
assert "temperature" not in kwargs
|
||||
|
||||
def test_provider_preferences_injected(self, agent):
|
||||
agent.base_url = "https://openrouter.ai/api/v1"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue