fix(kimi): preserve reasoning_content across replayed tool turns (salvage #13864)#13975
Merged
Conversation
19 tasks
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.
Salvages #13864 by @helix4u onto current main. Fixes the
HTTP 400: thinking is enabled but reasoning_content is missing in assistant tool call messageerror reported by drew_donaldson on Kimi/Moonshot when replaying long sessions.Root cause
Commit 063bc3c ("fix(kimi): send max_tokens, reasoning_effort, and thinking for Kimi/Moonshot") enabled thinking for Kimi/Moonshot. Kimi's strict-replay requires every assistant tool-call message to carry a
reasoning_contentfield when thinking is on. Sessions that predate that commit (or any turn wherereasoningwas empty) have no scratchpad to replay, so the field gets omitted and the API rejects the request.Changes
hermes_state.py: schema v7 addsreasoning_contentcolumn; idempotent ALTER TABLE migrationrun_agent.py:_build_assistant_messagecapturesreasoning_contentfrom API responses; new_copy_reasoning_content_for_apireplaces the two existingreasoning → reasoning_contentone-liners with a 3-tier fallback:reasoning_content(even empty string) winsreasoningif non-empty""to satisfy the strict APIgateway/session.py+gateway/run.py: threadreasoning_contentthrough transcript append/rewrite and branch-copyValidation
19/19 targeted tests pass.
Authorship preserved via cherry-pick. Closes #13864.