~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
fix(report): demote boilerplate truncation warning on bibliography removal (#6025) (#6380)
S7864e35e0336
diff --git a/changelog.d/6025.bugfix.md b/changelog.d/6025.bugfix.mdnew file mode 100644index 0000000000..130c338199--- /dev/null+++ b/changelog.d/6025.bugfix.md@@ -0,0 +1 @@+Demote subsection boilerplate truncation warning to `INFO` when the length reduction is driven by removing an unwanted trailing or embedded bibliography block emitted by small/quantized local LLMs, reserving `WARNING` for genuine over-stripping of substantive content.diff --git a/src/local_deep_research/report_generator.py b/src/local_deep_research/report_generator.pyindex 9c182c1d8a..d3238e452b 100644--- a/src/local_deep_research/report_generator.py+++ b/src/local_deep_research/report_generator.py@@ -915,7 +915,9 @@ class IntegratedReportGenerator:content, subsection_name, sibling_subsection_names)new_content = self._strip_leading_italic_purpose(new_content, purpose)+ pre_bib_len = len(new_content)new_content = self._strip_embedded_bibliographies(new_content)+ bib_chars_removed = pre_bib_len - len(new_content)# R2: fence-aware whitespace collapse — never rewrite inside code fencesfence_spans = _get_code_fence_spans(new_content)@@ -946,11 +948,27 @@ class IntegratedReportGenerator:"check for over-strip (R1/R3 regression)")elif len(new_content) < 0.5 * original_len:- logger.warning(- "Stripped subsection boilerplate heavily truncated content for "- f"'{section_name} > {subsection_name}': "- f"{original_len} -> {len(new_content)} chars"- )+ # If the truncation below 50% was driven by stripping an+ # embedded bibliography (where pre-bibliography content was+ # >= 50% and bib removal did the rest), this is expected+ # cleanup rather than an unexpected over-strip.+ if (+ bib_chars_removed > 0+ and pre_bib_len >= 0.5 * original_len+ and (original_len - pre_bib_len) < 0.25 * original_len+ ):+ logger.info(+ "Stripped embedded bibliography from subsection "+ f"'{section_name} > {subsection_name}': "+ f"{original_len} -> {len(new_content)} chars "+ "(expected cleanup; warning demoted to INFO)"+ )+ else:+ logger.warning(+ "Stripped subsection boilerplate heavily truncated content for "+ f"'{section_name} > {subsection_name}': "+ f"{original_len} -> {len(new_content)} chars"+ )else:logger.debug("Stripped subsection boilerplate for "diff --git a/tests/report/test_report_generator_helpers.py b/tests/report/test_report_generator_helpers.pyindex 1357b11d5c..8f4bc0d1d7 100644--- a/tests/report/test_report_generator_helpers.py+++ b/tests/report/test_report_generator_helpers.py@@ -682,6 +682,87 @@ class TestStripSubsectionBoilerplate:)assert "Prose body of the analysis." in result+ def test_warning_demoted_to_info_when_truncation_is_bibliography_only(+ self, generator, loguru_caplog+ ):+ # When an unwanted bibliography accounts for >50% reduction,+ # warning is demoted to INFO (expected cleanup, not an over-strip).+ prose = "Substantive analysis prose for this subsection.\n" * 20+ bib = "\n\n## Sources\n" + "\n".join(+ f"[{i}] https://example.com/source/{i}" for i in range(1, 100)+ )+ content = prose + bib+ assert len(content) > 3000++ with loguru_caplog.at_level("INFO"):+ result = self._strip(+ generator,+ content,+ name="Deep Dive Subsection",+ section="Main Section",+ )++ assert "## Sources" not in result+ assert "Substantive analysis prose" in result+ assert len(result) < 0.5 * len(content)+ # Verify warning was demoted to info+ assert (+ "Stripped embedded bibliography from subsection"+ in loguru_caplog.text+ )+ assert (+ "(expected cleanup; warning demoted to INFO)" in loguru_caplog.text+ )+ assert (+ "Stripped subsection boilerplate heavily truncated content"+ not in loguru_caplog.text+ )++ def test_warning_preserved_when_heavy_truncation_is_not_bibliography(+ self, generator, loguru_caplog+ ):+ # Heavy truncation (>50%) driven by non-bibliography removal must still WARN.+ long_heading = "### " + "A" * 200 + "\n\n"+ short_prose = "Short prose."+ content = long_heading + short_prose++ with loguru_caplog.at_level("WARNING"):+ result = self._strip(+ generator,+ content,+ name="A" * 200,+ section="Main Section",+ )++ assert result.strip() == short_prose+ assert len(result) < 0.5 * len(content)+ assert (+ "Stripped subsection boilerplate heavily truncated content"+ in loguru_caplog.text+ )++ def test_warning_preserved_when_content_emptied_by_strip(+ self, generator, loguru_caplog+ ):+ # If content is completely emptied, it must trigger the emptied warning.+ content = "## Sources\n" + "\n".join(+ f"[{i}] https://example.com/ref/{i}" for i in range(1, 5)+ )++ with loguru_caplog.at_level("WARNING"):+ result = self._strip(+ generator,+ content,+ name="Empty Subsection",+ section="Main Section",+ )++ assert result == ""+ assert (+ "Stripped subsection boilerplate emptied non-trivial content"+ in loguru_caplog.text+ )+# ── _strip_embedded_bibliographies ──