Fix Rich markup corrupting/crashing streamed answers and echoed input#1
Open
rajamohan1950 wants to merge 1 commit into
Open
Fix Rich markup corrupting/crashing streamed answers and echoed input#1rajamohan1950 wants to merge 1 commit into
rajamohan1950 wants to merge 1 commit into
Conversation
Streamed AI answers were emitted via console.print(chunk) with Rich markup enabled, so any bracketed text in the model output (e.g. List[str], decorators, list literals) was interpreted as style tags. This silently dropped content (List[str] rendered as "List ") and could raise MarkupError on tag-like sequences such as [/close], aborting the response mid-stream. The same class of bug affected the echoed user question (default, non-streaming path) and the debug keywords line, where untrusted text was embedded inside markup f-strings. - Print streamed chunks with markup=False, highlight=False - Escape the question and keywords with rich.markup.escape
6bf97ed to
25af0df
Compare
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.
Summary
The tool's own output is fed to
rich'sConsole.printwith markup enabled, so bracketed text is interpreted as Rich style tags. For a code Q&A tool this is common in both answers and questions (type hints likeList[str], decorators, list literals, closing-tag-like sequences), which leads to silent content loss and, in some cases, an outright crash.Root cause & impact
-s/CODE_QNA_STREAM=true) — each chunk was printed viaconsole.print(chunk)with markup enabled:List[str]renders asList— the[str]is swallowed as a bogus style tag, so the user sees a subtly wrong answer.[/close]raisesrich.errors.MarkupError, aborting the response mid-stream.console.print(f"...{question}")embeds raw user input inside a markup string, so e.g.code-qna "what is List[str]?"corrupts the echo andcode-qna "[/x]"crashes before answering.The non-streaming answer path is unaffected because it wraps output in
Markdown(answer).Changes
markup=False, highlight=False.rich.markup.escape.Test plan
List[str],a[0]+b[1], and[/close]now stream through intact with no loss and noMarkupError.List[str]and[/x]echo correctly and no longer crash.code-qna -s "what does List[str] mean?"against a sample repo.