Skip to content

fix: 模型级温度不再被任务侧显式温度覆盖 - #1877

Open
kldsjfas wants to merge 2 commits into
Mai-with-u:devfrom
kldsjfas:fix/1833-model-temperature-override
Open

kldsjfas wants to merge 2 commits into
Mai-with-u:devfrom
kldsjfas:fix/1833-model-temperature-override

Conversation

@kldsjfas

@kldsjfas kldsjfas commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

请填写以下内容

    • main 分支 禁止修改,请确认本次提交的分支 不是 main 分支
    • 我确认我阅读了贡献指南
    • 本次更新类型为:BUG修复
    • 本次更新类型为:功能新增
    • 本次更新是否经过测试
    • 如果本次修改涉及 src/A_memorix,我确认已阅读 src/A_memorix/MODIFICATION_POLICY.md,不涉及则无需勾选
  1. 请填写破坏性更新的具体内容(如有): 无。行为变化仅影响显式配置了模型级 temperature 的模型(原先会被任务侧温度覆盖,现在以模型级为准),未配置模型级温度的场景行为完全不变。
  2. 请简要说明本次更新的内容和目的:

模型列表里给模型配置的自定义温度目前会被任务侧显式传入的温度覆盖。像 Kimi-K2.6 这类只接受固定温度的模型,即使已经在模型配置里设置了 temperature=0.6,A_Memorix 证据分类、各类 learner、WebUI 的模型测试(硬编码 temperature=0.0)等调用点仍然按自己的温度发请求,直接返回 400(invalid temperature),并触发无意义的模型切换。

原因在 LLMOrchestrator._resolve_effective_temperature 的优先级:调用方显式传参 > 模型级配置 > extra_params > 任务配置。#1820 把 A_memorix 的分类温度做成了可配置,但配置出来的值同样属于“调用方显式传入”,还是会压过模型级设置,所以 #1833 在其合并之后仍然出现。

本次把模型级 temperature 提到最高优先级,在解析函数单点修复,覆盖所有调用点;ModelInfo.temperature 的字段说明同步改为“会覆盖任务配置和调用方显式传入的温度”。

测试:新增 pytests/utils_test/test_effective_temperature.py 覆盖四级优先级取值;全量 pytest 与 dev 基线对比无新增失败。

其他信息

Summary by CodeRabbit

  • 新功能

    • 调整了温度参数的生效优先级:当模型信息中显式提供 temperature 时,将优先使用该值,而不再以调用方传入的 temperature 为主。
    • 当模型级温度缺失时,会按新的回退链路继续使用调用方显式值、额外参数默认值以及任务配置兜底。
  • 测试

    • 新增并完善了温度解析优先级的单测,覆盖多种组合场景(包括显式值与 extra_params.temperature 同时存在时的覆盖关系)。

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 27899a26-b64c-4e03-8f43-c715e77d2b2a

📥 Commits

Reviewing files that changed from the base of the PR and between 57401c5 and 8570bd7.

📒 Files selected for processing (1)
  • pytests/utils_test/test_effective_temperature.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • pytests/utils_test/test_effective_temperature.py

Walkthrough

本次改动调整了 _resolve_effective_temperature 的温度优先级逻辑,使模型级 model_info.temperature 优先于调用方显式传入的 temperature,更新了相关文档字符串及 ModelInfo.temperature 字段说明,并新增测试模块验证四种温度来源优先级场景。

Changes

温度解析优先级修复

Layer / File(s) Summary
温度解析核心逻辑与文档更新
src/llm_models/utils_model.py, src/config/model_configs.py
_resolve_effective_temperature 优先级顺序调整为模型级温度优先于调用方显式温度,方法文档字符串与 ModelInfo.temperature 字段说明同步更新。
温度优先级单元测试
pytests/utils_test/test_effective_temperature.py
新增测试模块,通过 _FixedTaskOrchestrator_build_orchestrator_build_model_info 辅助函数,覆盖模型级覆盖、显式温度、extra_params 默认值及任务配置兜底四种优先级分支。

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 标题准确概括了本次核心改动:提高模型级 temperature 的优先级,避免被任务侧显式温度覆盖。
Description check ✅ Passed 描述基本覆盖了模板要求的分支确认、更新类型、测试、破坏性更新、内容目的和关联 Issue。
Linked Issues check ✅ Passed 修复将模型级 temperature 提升为最高优先级,并新增测试覆盖相关优先级规则,符合 #1833 的目标。
Out of Scope Changes check ✅ Passed 变更集中在温度解析逻辑、相关文档和单测,没有明显超出问题范围的改动。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
pytests/utils_test/test_effective_temperature.py (1)

1-54: 🎯 Functional Correctness | 🔵 Trivial

测试覆盖了新的四级优先级分支,整体结构清晰。

不过目前用例未覆盖 model_info.temperature 为空、但 extra_params["temperature"] 与调用方显式 temperature 同时存在时的冲突场景——该场景与 src/llm_models/utils_model.py_resolve_effective_temperature 的优先级设计缺口直接相关,已在该文件对应位置提出。建议在核心逻辑修正后同步补充此分支的测试。

🤖 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 `@pytests/utils_test/test_effective_temperature.py` around lines 1 - 54, 补充
`_resolve_effective_temperature` 的冲突场景测试:当前 `test_effective_temperature.py`
只覆盖了单一路径优先级,未验证 `model_info.temperature` 为空时,`extra_params["temperature"]`
与调用方显式 `temperature` 同时存在的分支。请在
`test_model_level_temperature_overrides_explicit_temperature`、`test_explicit_temperature_used_when_model_level_absent`
等现有用例旁新增一个测试,直接针对 `LLMOrchestrator._resolve_effective_temperature`,明确断言该场景下应遵循你在
`src/llm_models/utils_model.py` 中修正后的优先级规则。
🤖 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 `@pytests/utils_test/test_effective_temperature.py`:
- Around line 1-54: 补充 `_resolve_effective_temperature` 的冲突场景测试:当前
`test_effective_temperature.py` 只覆盖了单一路径优先级,未验证 `model_info.temperature`
为空时,`extra_params["temperature"]` 与调用方显式 `temperature` 同时存在的分支。请在
`test_model_level_temperature_overrides_explicit_temperature`、`test_explicit_temperature_used_when_model_level_absent`
等现有用例旁新增一个测试,直接针对 `LLMOrchestrator._resolve_effective_temperature`,明确断言该场景下应遵循你在
`src/llm_models/utils_model.py` 中修正后的优先级规则。

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1c1b73f4-a005-40fc-a1ec-0351d5c5b9e8

📥 Commits

Reviewing files that changed from the base of the PR and between e2990a5 and 57401c5.

📒 Files selected for processing (3)
  • pytests/utils_test/test_effective_temperature.py
  • src/config/model_configs.py
  • src/llm_models/utils_model.py

@kldsjfas

kldsjfas commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

已补充该场景的用例:模型级温度为空时,调用方显式温度优先于 extra_params 中的默认值(test_explicit_temperature_overrides_extra_params_default)。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant