Skip to content

fix(agent): preserve zero temperature setting - #16897

Merged
JinHai-CN merged 1 commit into
infiniflow:mainfrom
taek105:fix/16683-preserve-zero-temperature
Jul 14, 2026
Merged

JinHai-CN merged 1 commit into
infiniflow:mainfrom
taek105:fix/16683-preserve-zero-temperature

Conversation

@taek105

@taek105 taek105 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

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.

Why

LLMParam.gen_conf() only forwards temperature values greater than zero. This causes an explicitly
configured temperature=0 to be omitted, allowing the model provider to use its default value
instead.

PR #15389 fixed zero-valued parameters in the REST chat completion routes, but the Agent LLM
component uses a separate configuration path where the issue remains.

Testing

  • ruff format --check agent/component/llm.py test/unit_test/agent/component/test_llm_prompt.py
  • ruff check agent/component/llm.py test/unit_test/agent/component/test_llm_prompt.py
  • git diff --check
  • Targeted pytest pending PR CI; local dependency installation failed

Fixes #16683

@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

An error occurred during the review process. Please try again later.

📝 Walkthrough

Walkthrough

The temperature condition in LLMParam.gen_conf now accepts zero when enabled. A unit test verifies that the generated configuration contains "temperature": 0.

Changes

Temperature Configuration

Layer / File(s) Summary
Emit and test zero temperature
agent/component/llm.py, test/unit_test/agent/component/test_llm_prompt.py
gen_conf changes the temperature check to accept values greater than or equal to zero, and a test validates zero-temperature output when enabled.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: cike8899

Poem

I’m a rabbit with a dial set low,
Zero degrees now gets to flow.
Through config fields, neat and bright,
The test confirms the value’s right.
Hop, hop—precise control tonight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: preserving zero temperature in Agent LLM settings.
Description check ✅ Passed The description matches the template's Summary section and adds useful context, testing notes, and issue reference.
Linked Issues check ✅ Passed The changes address #16683 by forwarding enabled temperature=0 values while still excluding negative temperatures.
Out of Scope Changes check ✅ Passed The PR is limited to the Agent LLM config fix and a regression test, with no clear unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@taek105
taek105 marked this pull request as ready for review July 14, 2026 05:56
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. 🧪 test Pull requests that update test cases. labels Jul 14, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
test/unit_test/agent/component/test_llm_prompt.py (1)

64-71: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Also test that negative temperatures remain excluded.

This regression test covers zero, but the PR contract also requires negative values to be omitted. Add a focused assertion for an enabled negative temperature.

Suggested test
+def test_gen_conf_excludes_negative_temperature():
+    param = LLMParam()
+    param.temperature = -0.1
+    param.temperatureEnabled = True
+
+    assert "temperature" not in param.gen_conf()
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/unit_test/agent/component/test_llm_prompt.py` around lines 64 - 71, Add
a focused assertion in test_gen_conf_includes_zero_temperature_when_enabled, or
a nearby dedicated test, that sets temperature to a negative value with
temperatureEnabled enabled and verifies gen_conf() omits the "temperature" key.
Preserve the existing zero-temperature assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@test/unit_test/agent/component/test_llm_prompt.py`:
- Around line 64-71: Add a focused assertion in
test_gen_conf_includes_zero_temperature_when_enabled, or a nearby dedicated
test, that sets temperature to a negative value with temperatureEnabled enabled
and verifies gen_conf() omits the "temperature" key. Preserve the existing
zero-temperature assertion.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c83088a8-ef35-4f2a-948f-10431b365f65

📥 Commits

Reviewing files that changed from the base of the PR and between 654fc88 and 6348912.

📒 Files selected for processing (2)
  • agent/component/llm.py
  • test/unit_test/agent/component/test_llm_prompt.py

@JinHai-CN JinHai-CN added the ci Continue Integration label Jul 14, 2026
@JinHai-CN
JinHai-CN merged commit 760203b into infiniflow:main Jul 14, 2026
18 of 20 checks passed
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (1323669) to head (6348912).
⚠️ Report is 16 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16897   +/-   ##
=======================================
  Coverage   93.16%   93.16%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          668      668           
  Misses         29       29           
  Partials       20       20           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@taek105
taek105 deleted the fix/16683-preserve-zero-temperature branch July 14, 2026 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:XS This PR changes 0-9 lines, ignoring generated files. 🧪 test Pull requests that update test cases.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Question]: set model temperature = 0 not working in agent

2 participants