fix(dictation): stop leaking raw <think> content when stripped output is empty#431
Open
postoso wants to merge 1 commit into
Open
fix(dictation): stop leaking raw <think> content when stripped output is empty#431postoso wants to merge 1 commit into
postoso wants to merge 1 commit into
Conversation
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.
What
In the non-streaming LLM response parsers,
contentfell back to the RAW content when the thinking-stripped content was empty (cleanedContent.isEmpty ? rawContent : cleanedContent). When a reply is all thinking (<think>...</think>with nothing after),cleanedContentis empty, so the raw tagged text leaked downstream and got inserted into the user's document. The streaming path already returns empty (which trips the existingemptyResponseerror), so the two paths disagreed.How
Return
cleanedContentdirectly at both parser sites (parseResponsesResponse,parseMessageResponse). An all-thinking reply now yields empty content and trips the existing empty-response handling instead of leaking the tags, matching the streaming path. The two parsers are widened fromprivateto internal so the new tests can reach them; behavior is otherwise unchanged.Tests
New
LLMClientThinkingTagTests(5 methods): all-thinking yields empty, content after</think>is kept clean, plain content is unchanged, covering both the chat-completions and Responses API parsers.xcodebuild testis green andswiftlint --strictis clean.