Skip to content

fix(llm): 官方 OpenAI gpt-5 系列不下发 temperature,修复验证 400(#857) - #888

Merged
H-Chris233 merged 3 commits into
Open-Less:betafrom
H-Chris233:codex/pr-857-gpt5-temperature-fix
Aug 3, 2026
Merged

fix(llm): 官方 OpenAI gpt-5 系列不下发 temperature,修复验证 400(#857)#888
H-Chris233 merged 3 commits into
Open-Less:betafrom
H-Chris233:codex/pr-857-gpt5-temperature-fix

Conversation

@H-Chris233

@H-Chris233H-Chris233 commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

User description

背景

issue #857:OpenAI 预设 + gpt-5 系列模型验证返回「供应商接口返回 400」,换回 gpt-4 系列正常。

根因

  • OpenLess 对所有内置 provider(含 openai)强制下发 temperature: 0.3openai_compatible_temperature_for_providerDEFAULT_TEMPERATURE),且 UI 只对 custom 预设开放温度配置。
  • OpenAI 官方 gpt-5 系列(gpt-5 / gpt-5-mini / gpt-5-nano / gpt-5.5 等)在 Chat Completions 中只接受默认 temperature=1,传 0.3 会被 400 拒绝(Unsupported value: 'temperature' ... Only the default (1) value is supported.)。
  • 验证按钮走的是一次真实 polish 调用(validate_llm_providerchat/completions),所以同样的 400 直接体现在验证上;gpt-4 系列无此限制,因此换回 gpt-4 正常。

修复(KISS)

  • chat_body()openai 官方渠道 + gpt-5 模型* 不再下发 temperature,由服务端用默认值(1);其余模型(gpt-4 等)保持原 0.3 行为。
  • chat_body() 是所有 OpenAI 兼容 LLM 请求(验证/润色/翻译/QA/流式)的唯一下发点,一处修改全局生效。
  • custom 预设的用户显式温度配置不受影响(issue 绕过路径 custom + temperature=1 继续可用)。

测试

  • cargo test --lib polish::tests:66 passed(新增 3 个:gpt-5 全家不下发、gpt-4 保持 0.3、custom 显式温度不受影响)
  • cargo test --lib commands::providers:13 passed

PR Type

Bug fix, Tests


Description

  • Fix OpenAI gpt-5 validation 400 by omitting temperature

  • Add gpt-5 family detection for official OpenAI models

  • Add tests for gpt-5, gpt-4, and custom provider behavior


Diagram Walkthrough

flowchart LR
A["chat_body()"] --> B{"official OpenAI provider & gpt-5* model?"}
B -- "yes" --> C["omit temperature"]
B -- "no" --> D["send temperature (default or custom)"]
Loading

File Walkthrough

Relevant files
Bug fix
polish.rs
Omit temperature for OpenAI gpt-5 models

openless-all/app/src-tauri/src/polish.rs

  • Bypass temperature setting in chat_body() for official OpenAI gpt-5
    family
  • Add openai_model_is_gpt5_family() helper for model normalization
  • Add unit tests for gpt-5 omission, gpt-4 default, and custom provider
    temperature
+77/-1

OpenAI 官方 gpt-5 系列在 Chat Completions 只接受默认 temperature=1,
传 0.3(内置默认)会被 400 拒绝,导致验证/润色全部失败。
官方渠道的 gpt-5* 不再下发 temperature,由服务端用默认值;
gpt-4 等其余模型保持原行为。custom 预设显式温度不受影响。
@github-actions

github-actionsBot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

(Review updated until commit d73294b)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis ✅

857 - PR Code Verified

Compliant requirements:

  • 官方 OpenAI 渠道 + gpt-5* 模型不再下发 temperature,规避 400
  • gpt-4 等其它模型保持原有 temperature 行为
  • custom 预设显式配置的 temperature 不受影响

Requires further human verification:

  • 需要连接真实 OpenAI 接口验证 gpt-5 系列不再返回 400(代码审查无法替代端到端验证)
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

Android 胶囊走原生 overlay,tauri::WebviewWindow 无
set_ignore_cursor_events(桌面专用),导致 Android cargo check
编译失败(E0599)。cfg 门控跳过,触摸交互由系统处理。
@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit 4d55096

…emperature-fix
# Conflicts:
#	openless-all/app/src-tauri/src/coordinator/capsule_focus.rs
@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit d73294b

@H-Chris233
H-Chris233 merged commit 26cd012 into Open-Less:betaAug 3, 2026
5 checks passed
@H-Chris233
H-Chris233 deleted the codex/pr-857-gpt5-temperature-fix branch August 3, 2026 08:45
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@H-Chris233