fix: set Kimi temperature to 0.6 when thinking is disabled#747
Conversation
The Kimi API requires temperature=0.6 when thinking is disabled; without it, toggling thinking off causes a 400 error with "invalid temperature: only 0.6 is allowed". This fix applies the default only when no explicit temperature has been configured, preserving user overrides (e.g., via ProviderConfig or env var). Fixes MoonshotAI#686.
🦋 Changeset detectedLatest commit: c120957 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c1209577d3
ℹ️ 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".
| * while preserving user overrides (e.g., via ProviderConfig or env var). | ||
| */ | ||
| function applyDisabledThinkingTemperatureDefault(params: Record<string, unknown>): void { | ||
| if (params['temperature'] !== undefined) return; |
There was a problem hiding this comment.
Override env temperature when disabling thinking
For users who set KIMI_MODEL_TEMPERATURE, this guard preserves that value even after ConfigState.provider applies withThinking(this.thinkingLevel) and then applyKimiEnvSamplingParams reads the env var into temperature. When they toggle Kimi thinking off, the request still sends thinking: { type: 'disabled' } with the non-0.6 env temperature, so it continues to hit the same Moonshot 400 (only 0.6 is allowed) instead of applying the disabled-thinking fix.
Useful? React with 👍 / 👎.
Problem
When thinking is toggled off in the Kimi provider, the API returns a 400 error:
The Kimi API requires
temperature=0.6when thinking is disabled, andtemperature=1.0when thinking is enabled. Currently, no default temperature is set, so toggling thinking off causes a hard error.Solution
Apply a default temperature at the wire level (in the
generatemethod) only when:temperaturehas been configured by the userthinking.type === 'disabled'This approach is chosen because it preserves user overrides from
ProviderConfig, environment variables, or explicitwithGenerationKwargscalls, and it only applies the default at the last moment (when building the actual request parameters).Implementation
applyDisabledThinkingTemperatureDefault()helper inpackages/kosong/src/providers/kimi.tscreateParamsis assembled but before the request is sentTests
All 64 tests in
packages/kosong/test/kimi.test.tspass.References