From 760203be42610cb7a042ce1ff925122697fd8b0f Mon Sep 17 00:00:00 2001 From: hyotaek kim <101572128+taek105@users.noreply.github.com> Date: Tue, 14 Jul 2026 21:10:51 +0900 Subject: [PATCH] fix(agent): preserve zero temperature setting (#16897) ### Summary - Preserve an explicitly enabled `temperature=0` in the Agent LLM configuration. - Continue excluding invalid negative temperature values. - Add a focused regression test to the existing Agent LLM test file. Fixes #16683 --- agent/component/llm.py | 2 +- test/unit_test/agent/component/test_llm_prompt.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/agent/component/llm.py b/agent/component/llm.py index f50bd22edd..dbafe0267e 100644 --- a/agent/component/llm.py +++ b/agent/component/llm.py @@ -70,7 +70,7 @@ class LLMParam(ComponentParamBase): if int(self.max_tokens) > 0 and get_attr("maxTokensEnabled"): conf["max_tokens"] = int(self.max_tokens) - if float(self.temperature) > 0 and get_attr("temperatureEnabled"): + if float(self.temperature) >= 0 and get_attr("temperatureEnabled"): conf["temperature"] = float(self.temperature) if float(self.top_p) > 0 and get_attr("topPEnabled"): conf["top_p"] = float(self.top_p) diff --git a/test/unit_test/agent/component/test_llm_prompt.py b/test/unit_test/agent/component/test_llm_prompt.py index ebc011b08b..97db27e9c3 100644 --- a/test/unit_test/agent/component/test_llm_prompt.py +++ b/test/unit_test/agent/component/test_llm_prompt.py @@ -59,3 +59,13 @@ def test_fit_messages_uses_default_context_when_max_length_zero(): ) assert err is None assert msg_fit[-1]["content"] == "User query: test" + + +@pytest.mark.p1 +def test_gen_conf_includes_zero_temperature_when_enabled(): + """Include an explicitly enabled zero temperature in the model configuration.""" + param = LLMParam() + param.temperature = 0 + param.temperatureEnabled = True + + assert param.gen_conf()["temperature"] == 0