Repository navigation
[Feat] kimi-k3: Read the thinking object and map reasoning effort onto K3 tiers - #48776
Merged
Merged
Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
41 of 42 tasks
…ect thinking on k3; keep is accepted and ignored
…the effort parser with reasoning.effort
Collaborator
Author
|
/rerun-test test_protocol.py test_serving_chat.py |
Contributor
|
🚀 |
Collaborator
Author
|
/tag-and-rerun-ci |
kpham-sgl
added a commit
that referenced
this pull request
Nov 10, 2026
This was referenced Nov 12, 2026
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.
Port of #48414
Takes the Kimi-K3 request-side changes from #48414: the
thinkingobject, the reasoning-effort tiers, the chat-template-kwarg checks, and bare-string image URLs. The protocol and serving hunks are applied hunk by hunk, and the matching tests come along.Against the raw port:
response_format" change are not ported. Main already has K3-gated versions of all three ([Fix] kimi-k3: Validate message-level tools and let a forced call override JSON response_format #48481), and the branch versions would apply to every model. The branch tests for them (TestMessageLevelTools, the tworesponse_formattests, and the split developer message in an existing test) stay on the branch as well.TestThinkingParam.test_unknown_type_rejectedis not ported.thinkingstays a plain dict on the request, so an unknowntypeis rejected only by the K3 serving path, never at parse time. The test fails on the branch too.test_keep_all_acceptedis dropped.test_keep_is_acceptedcovers the same case.Summary
thinkingobject (protocol.py).thinking.effortoutranksreasoning.effortandreasoning_effort.thinking.type: "disabled"turns reasoning off. Athinkingobject with notypeturns it on, unless an effort has already decided the toggle.chat_template_kwargsstill overrides all of these._validate_kimi_k3_request, called once next to the MiniMax-M3 one).thinkingmust be an object whosetypeis enabled, disabled, adaptive, or absent; anything else is a 400.keepand other keys are accepted and ignored. The message-level tool checks main already had move into the same function.minimal/lowtolow,medium/hightohigh, andxhigh/ultra/maxtomax. K3.1 keepsmediumas its own tier. No effort is forwarded when thinking is off. A float or unknown effort is a 400; before, it logged a warning and fell back to the encoder default.chat_template_kwargson K3.add_generation_promptis dropped, liketokenize.conversationandtoolsare rejected. Athinking_effortoutside the model's tiers is rejected."image_url": "<url>"parses as{"url": "<url>"}.Changes to existing code
thinkingobject now sets the reasoning toggle. Before, a client'sthinkingdict reached only the templates that read it (MiniMax-M3). Now the request normalizer also reads it for every model:thinking.typefillschat_template_kwargs.thinkingandenable_thinking(withsetdefault, so explicit kwargs still win).thinking.effortbecomesreasoning_effort. It is parsed by the same_parse_effortasreasoning.effort, so tiers, numbers, and numeric strings are accepted, and anything else is a 422 namingthinking.effort.{"type": "adaptive"}now turns thinking on for a Qwen3 or DeepSeek template, and MiniMax-M3 now seesthinking.effortasreasoning_effort.image_urlis accepted where it was a validation error.chat_encoding_spec == "kimi_k3".Verification
Unit tests, run locally (macOS, CPU, xgrammar 0.2.7 as pinned), on this branch merged with current main:
test_protocol.py: 63 passed. On main: 50 passed.test_serving_chat.py: 186 passed and 1 failed. On main: 172 passed and the same 1 failed (test_streaming_created_is_stable_across_chunks), becausetml-renderersis not installed locally.registered/unit/entrypoints/openai,registered/unit/entrypoints/anthropic, and the reasoning-parser tests fails the same 18 cases as main and no others.pre-commit runpasses on the changed files.CI States
Latest PR Test (Base): 🚫 Run #42796650466
Latest PR Test (Extra): ❌ Run #42796650324
Latest PR Test (AMD ROCm 10): ⏳ Run #42796650708
Tip
Base CI only covers the core cases, and its workload may not exercise your change. Use
/rerun-testto run the tests your change touches, or copy this prompt for an agent: