Skip to content

~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.

Fix repetitive sections in detailed reports by preserving question history

LearningCircuitd27443382fd8
diff --git a/src/local_deep_research/advanced_search_system/strategies/base_strategy.py b/src/local_deep_research/advanced_search_system/strategies/base_strategy.py
index 599d19c4ee..c25073f53e 100644
--- a/src/local_deep_research/advanced_search_system/strategies/base_strategy.py
+++ b/src/local_deep_research/advanced_search_system/strategies/base_strategy.py
@@ -12,10 +12,18 @@ from loguru import logger
class BaseSearchStrategy(ABC):
"""Abstract base class for all search strategies."""
- def __init__(self, all_links_of_system=None, settings_snapshot=None):
+ def __init__(
+ self,
+ all_links_of_system=None,
+ settings_snapshot=None,
+ questions_by_iteration=None,
+ ):
"""Initialize the base strategy with common attributes."""
self.progress_callback = None
- self.questions_by_iteration = {}
+ # Create a new dict if None is provided (avoiding mutable default argument)
+ self.questions_by_iteration = (
+ questions_by_iteration if questions_by_iteration is not None else {}
+ )
# Create a new list if None is provided (avoiding mutable default argument)
self.all_links_of_system = (
all_links_of_system if all_links_of_system is not None else []
diff --git a/src/local_deep_research/advanced_search_system/strategies/source_based_strategy.py b/src/local_deep_research/advanced_search_system/strategies/source_based_strategy.py
index 80ab34ecd5..99c99867c1 100644
--- a/src/local_deep_research/advanced_search_system/strategies/source_based_strategy.py
+++ b/src/local_deep_research/advanced_search_system/strategies/source_based_strategy.py
@@ -51,9 +51,7 @@ class SourceBasedSearchStrategy(BaseSearchStrategy):
if search is not None
else get_search(settings_snapshot=settings_snapshot)
)
- self.progress_callback = None
-
- self.questions_by_iteration = {}
+ # Note: progress_callback and questions_by_iteration are already set by parent class
self.include_text_content = include_text_content
self.use_cross_engine_filter = use_cross_engine_filter
self.filter_reorder = filter_reorder
diff --git a/src/local_deep_research/report_generator.py b/src/local_deep_research/report_generator.py
index 9938c4abdb..4196c0683e 100644
--- a/src/local_deep_research/report_generator.py
+++ b/src/local_deep_research/report_generator.py
@@ -126,6 +126,27 @@ class IntegratedReportGenerator:
"""Research and generate content for each section in one step."""
sections = {}
+ # Preserve questions from initial research to avoid repetition
+ # This follows the same pattern as citation tracking (all_links_of_system)
+ existing_questions = initial_findings.get("questions_by_iteration", {})
+ if existing_questions:
+ # Set questions on both search system and its strategy
+ if hasattr(self.search_system, "questions_by_iteration"):
+ self.search_system.questions_by_iteration = (
+ existing_questions.copy()
+ )
+
+ # More importantly, set it on the strategy which actually uses it
+ if hasattr(self.search_system, "strategy") and hasattr(
+ self.search_system.strategy, "questions_by_iteration"
+ ):
+ self.search_system.strategy.questions_by_iteration = (
+ existing_questions.copy()
+ )
+ logger.info(
+ f"Initialized strategy with {len(existing_questions)} iterations of previous questions"
+ )
+
for section in structure:
logger.info(f"Processing section: {section['name']}")
section_content = []