fix(agent): handle deepseek empty reasoning#1571
Conversation
📝 WalkthroughWalkthroughThis change decouples the handling of non-empty and empty interleaved reasoning preservation in the context builder, introducing a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/main/presenter/agentRuntimePresenter/contextBuilder.ts`:
- Around line 331-333: The empty-reasoning fallback is currently guarded only by
preserveEmptyInterleavedReasoning, causing inconsistent behavior; change the
guards in the contexts where the fallback is returned (the block using
assistantContent and the similar block later) to require both
preserveInterleavedReasoning && preserveEmptyInterleavedReasoning before
returning [{ role: 'assistant', content: assistantContent }], so the
empty-preservation path is only taken when interleaved reasoning preservation is
enabled too.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: aaa19f72-66f6-42f0-ad76-7a498f10f28c
📒 Files selected for processing (5)
src/main/presenter/agentRuntimePresenter/contextBuilder.tssrc/main/presenter/agentRuntimePresenter/index.tssrc/shared/model.tstest/main/presenter/agentRuntimePresenter/agentRuntimePresenter.test.tstest/main/presenter/agentRuntimePresenter/contextBuilder.test.ts
| if (preserveEmptyInterleavedReasoning) { | ||
| return [{ role: 'assistant', content: assistantContent }] | ||
| } |
There was a problem hiding this comment.
Guard empty-reasoning fallback with the same composite condition.
Line 331 and Line 357 check preserveEmptyInterleavedReasoning directly, but empty-preservation elsewhere is gated by preserveInterleavedReasoning && preserveEmptyInterleavedReasoning. This creates inconsistent behavior when only the empty flag is true.
Proposed fix
- if (preserveEmptyInterleavedReasoning) {
+ if (shouldPreserveEmptyReasoning) {
return [{ role: 'assistant', content: assistantContent }]
}
@@
- if (preserveEmptyInterleavedReasoning) {
+ if (shouldPreserveEmptyReasoning) {
return [{ role: 'assistant', content: assistantContent }]
}Also applies to: 357-359
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/main/presenter/agentRuntimePresenter/contextBuilder.ts` around lines 331
- 333, The empty-reasoning fallback is currently guarded only by
preserveEmptyInterleavedReasoning, causing inconsistent behavior; change the
guards in the contexts where the fallback is returned (the block using
assistantContent and the similar block later) to require both
preserveInterleavedReasoning && preserveEmptyInterleavedReasoning before
returning [{ role: 'assistant', content: assistantContent }], so the
empty-preservation path is only taken when interleaved reasoning preservation is
enabled too.
Summary by CodeRabbit
Improvements
Tests