fix: pass reasoning_effort="none" when thinking is disabled for OpenAI-compatible providers#1363
fix: pass reasoning_effort="none" when thinking is disabled for OpenAI-compatible providers#1363lin200083 wants to merge 1 commit into
Conversation
…I-compatible providers
When [thinking] enabled = false in config.toml, thinkingEffortToReasoningEffort('off')
returned undefined, causing the reasoning_effort parameter to be omitted from API
requests. OpenAI-compatible providers like DeepSeek V4 Flash would then use their
server-side default (medium), keeping thinking mode on.
Fix this by mapping 'off' -> 'none' instead of undefined, so the request explicitly
signals that reasoning should be disabled.
Fixes MoonshotAI#1362
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5e1e666b5d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| switch (effort) { | ||
| case 'off': | ||
| return undefined; | ||
| return 'none'; |
There was a problem hiding this comment.
Gate
none to models that support reasoning effort
This maps the global off state to a wire value for every OpenAI-compatible request. ConfigState.provider always calls .withThinking(this.thinkingEffort), and non-thinking or unknown aliases resolve to off; then the OpenAI legacy/responses providers send any non-undefined value as reasoning_effort/reasoning.effort. For OpenAI configs using models such as gpt-4.1/gpt-4o, or gateways that do not accept none, the previously valid “thinking off” request now includes reasoning_effort: "none" and is rejected as an unsupported parameter/value. Please emit none only when the selected model/provider declares support for that disable value, otherwise keep omitting the parameter.
Useful? React with 👍 / 👎.
问题
当用户在
config.toml中设置[thinking] enabled = false时,第三方 OpenAI 兼容供应商(如 DeepSeek V4 Flash)仍然会保持思考模式。根因:
thinkingEffortToReasoningEffort(off)返回undefined,导致reasoning_effort参数在 API 请求中被省略。DeepSeek 服务端收到无reasoning_effort的请求时,使用自己的默认值medium,思考模式继续运行。修复
在
packages/kosong/src/providers/openai-common.ts中,将case "off": return undefined改为case "off": return "none"。generate()方法中的if (reasoningEffort !== undefined)条件因此会为 true,从而在请求体中显式发送reasoning_effort: "none",指令供应商关闭思考模式。验证
reasoningEffortToThinkingEffort("none")已经返回"off",正反映射一致ThinkPart时的自动回退逻辑(第 535 行)不会覆盖显式设置的"none",因为条件检查reasoningEffort === undefinedthinking协议)Closes #1362