Skip to content

fix(kimi): auto-set temperature based on thinking mode (#686)#693

Open
bj456736 wants to merge 1 commit into
MoonshotAI:mainfrom
bj456736:feat/kimi-temperature-thinking-auto
Open

fix(kimi): auto-set temperature based on thinking mode (#686)#693
bj456736 wants to merge 1 commit into
MoonshotAI:mainfrom
bj456736:feat/kimi-temperature-thinking-auto

Conversation

@bj456736

Copy link
Copy Markdown
Contributor

Problem

When users toggle thinking off in the TUI (or via config) for models like
, , or , the next request fails with:

This happens because

  • Thinking ON requires
  • Thinking OFF requires

Previously only set and ,
leaving unset. The API then defaulted to an incompatible value
when thinking was disabled.

Solution

Set the correct default inside :

Thinking mode Temperature
ON (low/medium/high/xhigh/max)
OFF

Users can still override via env var —
runs after and takes precedence.

Changes

  • : add to in
  • :
    • add wire-level test verifying (on) and (off)
    • add test confirming env-var override still works via
    • update existing state snapshot to include

Verification

�[1m�[30m�[46m RUN �[49m�[39m�[22m �[36mv4.1.4 �[39m�[90m/root/.openclaw/workspace/kimi-code�[39m

�[32m✓�[39m �[30m�[43m kosong �[49m�[39m test/kimi.test.ts �[2m(�[22m�[2m64 tests�[22m�[2m)�[22m�[32m 37�[2mms�[22m�[39m

�[2m Test Files �[22m �[1m�[32m1 passed�[39m�[22m�[90m (1)�[39m
�[2m Tests �[22m �[1m�[32m64 passed�[39m�[22m�[90m (64)�[39m
�[2m Start at �[22m 18:29:00
�[2m Duration �[22m 351ms�[2m (transform 122ms, setup 0ms, import 190ms, tests 37ms, environment 0ms)�[22m

Fixes #686

Moonshot API requires temperature=1.0 when thinking is enabled and
temperature=0.6 when disabled. Previously, toggling thinking off in the TUI
left the temperature unset (defaulting to API-side defaults), which caused:

  400 invalid temperature: only 0.6 is allowed for this model

This change sets the correct default temperature inside withThinking():
- thinking ON (low/medium/high/xhigh/max) → temperature=1.0
- thinking OFF → temperature=0.6

Users can still override via KIMI_MODEL_TEMPERATURE env var, which is applied
later in applyKimiEnvSamplingParams and takes precedence.

Fixes MoonshotAI#686

Signed-off-by: qkclaw <bj456736@users.noreply.github.com>
@changeset-bot

changeset-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 3abd4bf

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

@pkg-pr-new

pkg-pr-new Bot commented Jun 12, 2026

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

commit: 3abd4bf

@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: 3abd4bf47a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

// don't hit 400 errors after toggling thinking off; KIMI_MODEL_TEMPERATURE
// env var (applied later via applyKimiEnvSamplingParams) can still override.
const temperature = effort === 'off' ? 0.6 : 1.0;
return this._withGenerationKwargs({ reasoning_effort: reasoningEffort, temperature }).withExtraBody({

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve configured Kimi temperatures across thinking setup

When a Kimi provider is constructed with generationKwargs.temperature, this call overwrites it because ConfigState.provider builds providers as createProvider(this.providerConfig).withThinking(...). That means any caller using the public ProviderConfig/KimiOptions temperature setting loses their explicit sampling value unless they also reapply it later via the env override path; previously withThinking only touched thinking fields. Please only apply this auto temperature when no explicit temperature has already been configured, or otherwise preserve an explicit override consistently with the env-var override behavior.

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] kimi-for-coding 在关闭 thinking 模式后报错 invalid temperature: only 0.6 is allowed

1 participant