fix(kimi): auto-set temperature based on thinking mode (#686)#693
fix(kimi): auto-set temperature based on thinking mode (#686)#693bj456736 wants to merge 1 commit into
Conversation
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>
|
commit: |
There was a problem hiding this comment.
💡 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({ |
There was a problem hiding this comment.
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 👍 / 👎.
Problem
When users toggle thinking off in the TUI (or via config) for models like
, , or , the next request fails with:
This happens because
Previously only set and ,
leaving unset. The API then defaulted to an incompatible value
when thinking was disabled.
Solution
Set the correct default inside :
Users can still override via env var —
runs after and takes precedence.
Changes
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