Repository navigation
Surface think blocks from reasoning models instead of stripping - #6
Conversation
Surface reasoning traces from DeepSeek-R1, QwQ, Qwen3 etc instead of stripping them. First-class think parts with collapsible UI.
Previously, <think>...</think> tags from local reasoning models
(DeepSeek-R1, QwQ, Qwen3-coder) were silently stripped. Now they're
extracted and emitted as { thought: true, text } parts that the
existing Turn system surfaces as DeltaEventType.Thought events.
Changes:
- New thinkBlockParser.ts with extractThinkBlocks() for non-streaming
and StreamingThinkExtractor for cross-chunk streaming
- OpenAI generator: replaced filterThinkTags stripping with extraction
in both streaming and non-streaming paths
- Anthropic generator: handle 'thinking' and 'thinking_delta' content
blocks from Claude's extended thinking feature
11 parser tests + all 1873 existing tests pass.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThis change implements "Think Block Passthrough" functionality by introducing utilities to extract and preserve Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant OpenAIGen as OpenAI Generator
participant Extractor as StreamingThinkExtractor
participant Output as GenAI Parts
Client->>OpenAIGen: Stream chunk received
OpenAIGen->>Extractor: process(chunk)
alt Contains closing </think>
Extractor->>Extractor: Detect </think>, finalize think content
Extractor->>Output: { thought: true, text: thinkContent }
Extractor->>Output: { text: visibleText }
else No closing tag yet
Extractor->>Extractor: Buffer incomplete think block
Extractor->>Output: { text: visibleText }
end
Output->>Client: Emit parts with thought attribution
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
✨ 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. Comment |
Summary
<think>...</think>tags from reasoning models (DeepSeek-R1, QwQ, Qwen3-coder) were silently stripped{ thought: true, text }parts that the existing Turn system surfaces asDeltaEventType.ThoughteventsthinkBlockParser.ts—extractThinkBlocks()for non-streaming,StreamingThinkExtractorclass for cross-chunk streamingfilterThinkTagsstripping with extraction in both pathsthinkingandthinking_deltacontent blocks from Claude's extended thinkingTest plan
Summary by CodeRabbit
New Features
Documentation