fix(kimi): preserve reasoning_content across replayed tool turns#13864
Closed
helix4u wants to merge 1 commit into
Closed
fix(kimi): preserve reasoning_content across replayed tool turns#13864helix4u wants to merge 1 commit into
helix4u wants to merge 1 commit into
Conversation
Closed
6 tasks
Contributor
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.
What does this PR do?
Fixes the Kimi/Moonshot replay path that can send assistant tool-call messages back to the API without
reasoning_contentafter a resumed or persisted session.The change preserves provider-native
reasoning_contentseparately from normalizedreasoning, carries it through SQLite persistence and gateway transcript rewrites, and uses the explicit provider field when rebuilding outbound API history. For Kimi and Moonshot coding endpoints, replayed assistant tool-call messages now sendreasoning_content: ""instead of omitting the field entirely when thinking is enabled and no scratchpad survived.Related Issue
N/A
Type of Change
Changes Made
hermes_state.pyto persistreasoning_contenton assistant messages and restore it during conversation replay.run_agent.pyto preserve provider-nativereasoning_contentwhen normalizing assistant messages and to prefer that field when rebuilding outbound API messages.reasoning_contentfield even when the scratchpad is empty.reasoning_contentthrough gateway transcript append/rewrite and branch-copy paths ingateway/session.pyandgateway/run.py.tests/test_hermes_state.py,tests/gateway/test_session.py, andtests/run_agent/test_run_agent.pyfor migration, transcript rewrite, assistant normalization, and strict-provider replay.How to Test
kimi-codingonhttps://api.kimi.com/codingwith thinking enabled.thinking is enabled but reasoning_content is missing in assistant tool call message.source venv/bin/activate && scripts/run_tests.sh tests/test_hermes_state.py tests/gateway/test_session.py tests/run_agent/test_run_agent.py -k 'reasoning_content or schema_version or migration_from_v2 or RewriteTranscriptPreservesReasoning or TestReasoningReplayForStrictProviders or TestBuildAssistantMessage'.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
Repro symptom before the fix: