fix(core): accept thought-only responses in GeminiChat stream validation#2636
fix(core): accept thought-only responses in GeminiChat stream validation#2636
Conversation
Models using thinking/reasoning modes may emit only thought content without explicit text output. The stream validation previously rejected these as 'empty' responses. Now accepts responses that contain either text content or thought content when a finish reason is present. Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
📋 Review SummaryThis PR fixes 🔍 General Feedback
🎯 Specific Feedback🟡 High
🟢 Medium
🔵 Low
✅ Highlights
|
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
TLDR
Fixes
InvalidStreamErrorbeing thrown for responses containing only thought/reasoning content from thinking models. The stream validation now accepts both text and thought content as valid response content.Screenshots / Video Demo
Dive Deeper
Problem
The
GeminiChatstream validation inpackages/core/src/core/geminiChat.tswas rejecting responses that contained only thought/reasoning content (no visible text). This causedInvalidStreamErrorto be thrown for thinking models that use internal reasoning before producing output.Solution
Modified the validation logic to treat thought-only responses as valid. The condition now checks for
hasAnyContent = contentText || thoughtTextinstead of justcontentText.Changes
Reviewer Test Plan
Run the specific test file to verify all tests pass:
Test with a thinking/reasoning model (if available) to ensure thought-only responses are handled correctly.
Verify that empty responses (truly no content) still correctly throw
InvalidStreamError.Testing Matrix
Linked issues / bugs
Fixes #2530
Fixes #1700