fix: support <thought> tag rendering for Gemma 4 reasoning#12096
Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
Draft
fix: support <thought> tag rendering for Gemma 4 reasoning#12096roomote-v0[bot] wants to merge 1 commit intomainfrom
roomote-v0[bot] wants to merge 1 commit intomainfrom
Conversation
Gemma 4 31B uses <thought>...</thought> tags for its reasoning process, but Roo Code only recognized <think>...</think> tags. This change: - Updates TagMatcher to accept multiple tag names (string | string[]) - Adds "thought" as an additional recognized reasoning tag in all 4 providers (openai, base-openai-compatible, lm-studio, native-ollama) - Strips <thought> tags in presentAssistantMessage alongside <thinking> - Adds comprehensive test coverage for multi-tag matching Fixes #12093
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR attempts to address Issue #12093.
Problem
Gemma 4 31B outputs its reasoning process with
<thought>...</thought>tags, but Roo Code only recognized<think>...</think>tags for reasoning extraction. This caused the raw<thought>tags to appear in the chat UI instead of being rendered as reasoning content.Changes
src/utils/tag-matcher.ts- UpdatedTagMatcherto acceptstring | string[]for tag names, enabling multi-tag matching during streaming. When multiple tag names are provided, the matcher tracks candidate matches character-by-character and ensures close tags match their corresponding open tags.Provider updates (4 files) - Updated all
TagMatcherinstantiation sites to recognize both"think"and"thought"tags:src/api/providers/openai.tssrc/api/providers/base-openai-compatible-provider.tssrc/api/providers/lm-studio.tssrc/api/providers/native-ollama.tssrc/core/assistant-message/presentAssistantMessage.ts- Added stripping of<thought>/</thought>tags alongside the existing<thinking>tag stripping.src/utils/__tests__/tag-matcher.spec.ts- Added 13 tests covering single tag, multi-tag, streaming, mismatched tag, and transform scenarios.Testing
Feedback and guidance are welcome.
Interactively review PR in Roo Code Cloud