Skip to content

fix: pass reasoning_effort="none" when thinking is disabled for OpenAI-compatible providers#1363

Open
lin200083 wants to merge 1 commit into
MoonshotAI:mainfrom
lin200083:fix/reasoning-effort-off-none
Open

fix: pass reasoning_effort="none" when thinking is disabled for OpenAI-compatible providers#1363
lin200083 wants to merge 1 commit into
MoonshotAI:mainfrom
lin200083:fix/reasoning-effort-off-none

Conversation

@lin200083

Copy link
Copy Markdown

问题

当用户在 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 === undefined
  • 修复仅影响 OpenAI 兼容 provider,不影响 Kimi 原生 provider(使用自有 thinking 协议)

Closes #1362

…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
@changeset-bot

changeset-bot Bot commented Jul 4, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 5e1e666

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 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';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

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.

[Bug] 第三方 OpenAI 兼容供应商:关闭 thinking 模式时未传递 reasoning_effort=none

1 participant