fix(run_agent): prevent reasoning_content regression in DeepSeek/Kimi tool-call replay (#15812)#15883
fix(run_agent): prevent reasoning_content regression in DeepSeek/Kimi tool-call replay (#15812)#15883yes999zc wants to merge 1 commit into
Conversation
… tool-call replay PR #15478 fixed missing reasoning_content for DeepSeek API but introduced a regression: tool-call messages with genuine 'reasoning' field were overwritten by empty-string fallback before promotion. Re-order _copy_reasoning_content_for_api steps: 1. Preserve explicit reasoning_content 2. Promote 'reasoning' field (MOVED UP) 3. DeepSeek/Kimi tool-call empty-string fallback (MOVED DOWN) 4. Non-thinking provider cleanup Fixes #15812, relates #15749, #15478.
|
This regresses #15749 and reintroduces #15250. The current ordering — step 2 (DeepSeek/Kimi tool-call empty-string guard) before step 3 (
That's the whole point: when the active provider is DeepSeek/Kimi and the source message has A few other smell tests:
If #15812 is a real failure mode, the fix needs to be provider-of-origin-aware (e.g. only promote |
Salvage PR #15883 cherry-picked FocusFlow Dev's commit; release-notes CI needs the AUTHOR_MAP entry to attribute to the PR author's GitHub login rather than a placeholder.
Salvage PR NousResearch#15883 cherry-picked FocusFlow Dev's commit; release-notes CI needs the AUTHOR_MAP entry to attribute to the PR author's GitHub login rather than a placeholder.
Salvage PR NousResearch#15883 cherry-picked FocusFlow Dev's commit; release-notes CI needs the AUTHOR_MAP entry to attribute to the PR author's GitHub login rather than a placeholder.
Salvage PR NousResearch#15883 cherry-picked FocusFlow Dev's commit; release-notes CI needs the AUTHOR_MAP entry to attribute to the PR author's GitHub login rather than a placeholder.
Salvage PR NousResearch#15883 cherry-picked FocusFlow Dev's commit; release-notes CI needs the AUTHOR_MAP entry to attribute to the PR author's GitHub login rather than a placeholder.
Salvage PR NousResearch#15883 cherry-picked FocusFlow Dev's commit; release-notes CI needs the AUTHOR_MAP entry to attribute to the PR author's GitHub login rather than a placeholder.
Salvage PR NousResearch#15883 cherry-picked FocusFlow Dev's commit; release-notes CI needs the AUTHOR_MAP entry to attribute to the PR author's GitHub login rather than a placeholder.
Problem
PR #15478 fixed missing
reasoning_contentfor DeepSeek API calls, but introduced a regression in the logic order of_copy_reasoning_content_for_api.Regression Detail
When a message contains:
role: assistanttool_calls(non-empty)reasoning: "some genuine reasoning"(from a prior provider that uses the internalreasoningkey)reasoning_contentThe old (buggy) order was:
reasoning_content→ skip (not present)""→ return →reasoningnever promotedreasoningfield → never reachedResult: genuine reasoning content is lost, replaced by empty string.
Fix
Swap steps 2 and 3 so promotion happens before the empty-string fallback:
Verification
pytest tests/run_agent/test_deepseek_reasoning_content_echo.py -v: 21/21 passedKey regression test:
test_deepseek_reasoning_field_promoted→ PASSEDReferences
Checklist
run_agent.pymodified (single-file change)