Skip to content

fix: honor explicit thinking off on OpenAI-compatible providers - #1774

Merged
RealKai42 merged 1 commit into
mainfrom
fix/openai-legacy-thinking-off
Jul 16, 2026
Merged

fix: honor explicit thinking off on OpenAI-compatible providers#1774
RealKai42 merged 1 commit into
mainfrom
fix/openai-legacy-thinking-off

Conversation

@RealKai42

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue. Follow-up hardening on top of the #1616 auto-injection workaround; relates to the reasoning-effort audit that also produced #1765.

Problem

On OpenAI-compatible (chat completions) providers, an explicit thinking "off" collapsed to the same internal state as "never configured": withThinking('off') stored undefined, exactly like a provider that never saw withThinking. The history-based auto reasoning_effort injection (introduced for #1616) could not tell the two apart, so:

  • With think parts in history, a session whose thinking was explicitly turned Off still sent reasoning_effort: 'medium' — the UI said Off while the model kept reasoning (and billing for it).
  • Switching from a reasoning model to one that rejects the field (e.g. plain gpt-4o) leaked reasoning_effort into the next request, producing a 400.
  • thinkingEffort reported null for 'on', 'off', and unset alike, so request records fell back to 'off' and mislabeled an active 'on' as 'off'.

What changed

  • OpenAILegacyChatProvider (both the kosong copy and the vendored agent-core-v2 copy) now stores the requested effort verbatim in _thinkingEffort; the wire encoding is derived per request: 'off'/'on' send no field, concrete efforts pass through unchanged.
  • The feat(agent-core-v2): read and write the v1 session index file #1616 auto-injection now skips an explicit 'off' (still fires for 'on' and for "never configured", preserving the original workaround where it belongs).
  • thinkingEffort returns the actual effort, fixing records/telemetry that previously logged 'off' for 'on'.
  • Deliberately kept: no reasoning_effort: 'none' is sent — OpenAI's support for that value is model-dependent, and a blind 'none' would replace one incompatibility with another.
  • Tests: 6 new cases in the existing kosong suite; a new 9-case suite for the vendored agent-core-v2 copy (previously untested); updated two registry assertions that reflected on the removed private field.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

An explicit withThinking('off') collapsed to the same internal state as
"never configured" on chat-completions providers, so the history-based
auto reasoning_effort injection (#1616) silently switched reasoning back
on and could leak the field to models that reject it. Store the requested
effort verbatim and derive the wire encoding per request, suppress the
auto-enable for an explicit 'off', and report the accurate current effort
('on'/'off') instead of recording 'off' for both.
@changeset-bot

changeset-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f379528

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

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

@pkg-pr-new

pkg-pr-new Bot commented Jul 16, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@f379528
npx https://pkg.pr.new/@moonshot-ai/kimi-code@f379528

commit: f379528

@RealKai42
RealKai42 merged commit 3d5d630 into main Jul 16, 2026
15 checks passed
@RealKai42
RealKai42 deleted the fix/openai-legacy-thinking-off branch July 16, 2026 09:11
This was referenced Jul 16, 2026
ywh114 pushed a commit to ywh114/kimi-code that referenced this pull request Jul 19, 2026
…shotAI#1774)

An explicit withThinking('off') collapsed to the same internal state as
"never configured" on chat-completions providers, so the history-based
auto reasoning_effort injection (MoonshotAI#1616) silently switched reasoning back
on and could leak the field to models that reject it. Store the requested
effort verbatim and derive the wire encoding per request, suppress the
auto-enable for an explicit 'off', and report the accurate current effort
('on'/'off') instead of recording 'off' for both.
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