Skip to content

Conversation

@Skelectric
Copy link

Related GitHub Issue

Closes: # 9779

Description

  • Added generic interleaved thinking support for OpenAI-compatible providers
  • Implemented reasoning_content handling in streaming and non-streaming modes
  • Added turn boundary detection to properly clear reasoning content between user turns
  • Preserved reasoning content during tool call sequences
  • Added UI configuration for enabling interleaved thinking on custom models
  • Fixed UI ordering to display reasoning before tool calls
  • Added test coverage

Test Procedure

  • Tested with deepseek-chat and deepseek-reasoner model
  • Tested tool calls with reasoning content
  • Tested multi-turn conversations
  • Only tested with Deepseek models. No regression testing with other providers yet.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

Added "Interleaved Thinking" toggle to OpenAI provider
Screenshot 2025-12-08 at 2 10 55 PM

Documentation Updates

Does this PR necessitate updates to user-facing documentation?

Additional Notes

1. Streaming Content Behavior

Streaming content sometimes appears in chunks rather than smoothly. It's unclear whether this is due to my implementation or Deepseek's API behavior. This doesn't affect functionality but may impact user experience.

2. Reasoning Content Continuity Verification

While the implementation follows Deepseek's API requirements for passing reasoning_content back to the API, I haven't been able to definitively verify that Deepseek is receiving it correctly. However, the API would return 400 errors if not handled properly, and I haven't observed any such errors, suggesting the implementation is working correctly.

3. Limited Testing Scope

This has only been tested with Deepseek models (deepseek-chat and deepseek-reasoner). No regression testing has been performed with other OpenAI-compatible providers.

Get in Touch

DM skelectric on Discord for questions

skelectric added 7 commits December 8, 2025 19:07
Implement interleaved thinking mode support for DeepSeek V3.2 with
generic capability-based architecture for extensibility to other models.

Key changes:
- Core thinking mode: parameter handling, temperature override, streaming
- Multi-turn conversations: conditional reasoning clearing, turn detection
- Task persistence: reasoning_content save/restore
- Generic refactoring: capability flags replace model-specific checks

Makes it easy to add interleaved thinking for other models (Kimi K2,
Minimax M2) via capability flags.

Note: Checkpoint commit. Backward compatibility verification and
documentation pending. No manual testing performed yet.
…r OpenAI compatible providers

- Set supportsInterleavedThinking default to false in openAiModelInfoSaneDefaults
- Remove enabledR1Format fallback, rely solely on modelInfo.supportsInterleavedThinking flag
- Add UI checkbox in OpenAICompatible settings to configure supportsInterleavedThinking for custom models
- Fix turn detection to preserve reasoning_content when user messages contain tool_result blocks (still in tool call sequence)
- Fix turn detection when assistant stops sending tool calls after receiving tool results
- Convert tool_use blocks from assistant messages to OpenAI tool_calls format
- Convert tool_result blocks from user messages to tool role messages
- Preserve tool_calls when merging consecutive assistant messages

These changes ensure proper handling of tool calls and tool results in the
interleaved thinking message conversion pipeline, maintaining reasoning_content
preservation during tool call sequences while correctly clearing it between turns.
Update three tests to expect `true` (clear reasoning_content) when
assistant stops making tool calls after receiving results. These were
outdated after commit 477d917 changed the implementation to detect
tool sequence completion.
@roomote
Copy link
Contributor

roomote bot commented Dec 8, 2025

Rooviewer Clock   See task on Roo Cloud

All issues resolved. The implementation is clean and ready for merge.

  • Remove unused variables finalReasoningContent and finalContent in src/api/providers/openai.ts
Previous reviews

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

Comment on lines 219 to 221
let finalReasoningContent = ""
let finalContent = ""
let finalToolCalls: any[] = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two variables (finalReasoningContent and finalContent) are declared but never used. The comment on line 266 mentions "Track tool calls for debug logging" but only finalToolCalls is actually used (to accumulate tool call data). Consider removing these unused variables to reduce dead code.

Suggested change
let finalReasoningContent = ""
let finalContent = ""
let finalToolCalls: any[] = []
let finalToolCalls: any[] = []

Fix it with Roo Code or mention @roomote and request a fix.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels.

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

2 participants