Skip to content

fix(deep_research): join chapter body with real newline, not literal backslash-n#649

Open
Osamaali313 wants to merge 1 commit into
OpenBMB:mainfrom
Osamaali313:fix/report-read-chapter-newlines
Open

fix(deep_research): join chapter body with real newline, not literal backslash-n#649
Osamaali313 wants to merge 1 commit into
OpenBMB:mainfrom
Osamaali313:fix/report-read-chapter-newlines

Conversation

@Osamaali313

Copy link
Copy Markdown

Problem

report_read_chapter in functions/function_calling/deep_research.py joins the chapter body with the literal 2-character string "\n" (a backslash followed by n), not a newline:

# report_read_chapter, line 274
return "\\n".join(lines[start+1:end])

_read_report_lines builds lines with str.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 → returns read_text() (real newlines)

Only report_read_chapter uses "\\n". The result is that the tool returns the chapter with visible \n markers and no line breaks — one mangled line.

report_read_chapter is 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:

join separator real newlines output
Before "\\n" (backslash-n) 0 Background line 1.\nBackground line 2. (literal \n)
After "\n" (newline) 1 proper two-line text

Fix

One character:

return "\n".join(lines[start+1:end])

No test suite covers deep_research.py today; the fix restores consistency with the three sibling functions in the same file.

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.
Copilot AI review requested due to automatic review settings July 10, 2026 20:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants