fix(deep_research): join chapter body with real newline, not literal backslash-n#649
Open
Osamaali313 wants to merge 1 commit into
Open
fix(deep_research): join chapter body with real newline, not literal backslash-n#649Osamaali313 wants to merge 1 commit into
Osamaali313 wants to merge 1 commit into
Conversation
report_read_chapter joined the chapter body lines with the literal 2-character string "\n" instead of a newline, so the tool returned text with visible \n markers and no line breaks. _read_report_lines uses str.splitlines() (newlines stripped), and every sibling re-joins with "\n" (_save_report, report_outline); only this function used "\n". Use a real newline so multi-line chapters render correctly.
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.
Problem
report_read_chapterinfunctions/function_calling/deep_research.pyjoins the chapter body with the literal 2-character string"\n"(a backslash followed byn), not a newline:_read_report_linesbuildslineswithstr.splitlines()(line 175), which strips the newlines, so the body must be re-joined with a real newline to reconstruct the text. Every sibling in this module does exactly that:_save_report→"\n".join(lines)(line 181)report_outline→"\n".join(outline)(line 298)report_read→ returnsread_text()(real newlines)Only
report_read_chapteruses"\\n". The result is that the tool returns the chapter with visible\nmarkers and no line breaks — one mangled line.report_read_chapteris registered as an agent-callable tool (yaml_instance/deep_research_v1.yaml:347), so its return value is fed back to the model. Every time an agent reads a multi-line chapter back, it receives corrupted content — in the very deep-research workflow that assembles that report.Reproduction
Reading a chapter whose body is two lines (
Background line 1./Background line 2.) via the real_read_report_lines+_find_chapter_range:"\\n"(backslash-n)Background line 1.\nBackground line 2.(literal\n)"\n"(newline)Fix
One character:
No test suite covers
deep_research.pytoday; the fix restores consistency with the three sibling functions in the same file.