fix(kimi-coding): never send thinking{type:disabled} on the api.kimi.com/coding endpoint - #55488
Closed
Yackadaisical wants to merge 1 commit into
Closed
Conversation
…com/coding endpoint
The Anthropic-Messages-shaped coding endpoint (api.kimi.com/coding) rejects
thinking {"type": "disabled"} with HTTP 400 "invalid thinking: only
type=enabled is allowed for this model". KimiProfile.build_api_kwargs_extras
emitted disabled whenever a turn requested reasoning-off, so any cron/agent
run that disabled reasoning mid-session 400'd intermittently (the default
reasoning_effort path sends reasoning_effort instead and was unaffected).
Detect the /coding endpoint via the resolved base_url and degrade a disable
request to the only legal toggle there, {"type": "enabled"}; thinking cannot
be turned off on that endpoint anyway. The OpenAI-compat /v1 endpoint keeps
emitting disabled unchanged. Adds a regression test.
Contributor
|
Thanks for the focused regression report and test. Automated hermes-sweeper review found that this behavior is already implemented on current
Closing as already implemented on main. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Anthropic-Messages-shaped Kimi coding endpoint (
api.kimi.com/coding) rejectsthinking: {"type": "disabled"}with:KimiProfile.build_api_kwargs_extrasemits{"type": "disabled"}whenever a turn requests reasoning-off (reasoning_config={"enabled": False}). Any cron/agent run that disables reasoning mid-session therefore 400s intermittently — the defaultreasoning_effortpath sends a top-levelreasoning_effortinstead and is unaffected, so it only fails on the disable-reasoning turns.Observed in production on a daily cron using
provider: kimi-coding+base_url: https://api.kimi.com/coding: most days errored, days that never disabled reasoning succeeded.Fix
Detect the
/codingendpoint from the resolvedbase_urland degrade a disable request to the only value that endpoint accepts,{"type": "enabled"}(thinking cannot be turned off there anyway). The OpenAI-compat/v1endpoint keeps emittingdisabledunchanged, so no behavior changes for Moonshot/v1users.Tests
Adds
test_coding_endpoint_never_disables_thinking; all existing kimi-profile assertions still pass.