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.

refactor: move progress display helpers to base strategy

LearningCircuit6485f4e83714
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 bf34c5101b..b6ac8daa26 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
@@ -153,3 +153,68 @@ class BaseSearchStrategy(ABC):
progress_base + 10,
{"phase": "analysis_error", "error": str(error)},
)
+
+ def _emit_question_generation_progress(
+ self,
+ iteration: int,
+ progress_percent: int,
+ source_count: int = 0,
+ ) -> None:
+ """
+ Emit progress update for question generation phase.
+
+ Args:
+ iteration: Current iteration number
+ progress_percent: Current progress percentage
+ source_count: Number of sources found (for iteration > 1)
+ """
+ if iteration == 1:
+ self._update_progress(
+ "Generating initial search questions...",
+ progress_percent,
+ {"phase": "question_generation", "iteration": iteration},
+ )
+ else:
+ # Show previous questions and source count
+ prev_questions = self.questions_by_iteration.get(iteration - 1, [])
+ prev_display = "\n".join(f"• {q}" for q in prev_questions[:3])
+ if len(prev_questions) > 3:
+ prev_display += f"\n... and {len(prev_questions) - 3} more"
+ self._update_progress(
+ f"Generating questions from {source_count} sources:\n{prev_display}",
+ progress_percent,
+ {
+ "phase": "question_generation",
+ "type": "milestone",
+ "iteration": iteration,
+ "source_count": source_count,
+ },
+ )
+
+ def _emit_searching_progress(
+ self,
+ iteration: int,
+ questions: List[str],
+ progress_percent: int,
+ ) -> None:
+ """
+ Emit progress update for searching phase with questions as milestone.
+
+ Args:
+ iteration: Current iteration number
+ questions: List of questions being searched
+ progress_percent: Current progress percentage
+ """
+ questions_display = "\n".join(f"• {q}" for q in questions[:5])
+ if len(questions) > 5:
+ questions_display += f"\n... and {len(questions) - 5} more"
+ self._update_progress(
+ f"Searching iteration {iteration}:\n{questions_display}",
+ progress_percent,
+ {
+ "phase": "parallel_search",
+ "type": "milestone",
+ "iteration": iteration,
+ "questions": questions,
+ },
+ )
diff --git a/src/local_deep_research/advanced_search_system/strategies/focused_iteration_strategy.py b/src/local_deep_research/advanced_search_system/strategies/focused_iteration_strategy.py
index 4b5fd7c477..1429afda7f 100644
--- a/src/local_deep_research/advanced_search_system/strategies/focused_iteration_strategy.py
+++ b/src/local_deep_research/advanced_search_system/strategies/focused_iteration_strategy.py
@@ -151,34 +151,13 @@ class FocusedIterationStrategy(BaseSearchStrategy):
)
# Show context-aware progress message for question generation
- if iteration == 1:
- self._update_progress(
- "Generating initial search questions...",
- iteration_progress + 2,
- {
- "phase": "question_generation",
- "iteration": iteration,
- },
- )
- else:
- # Show previous questions and source count
- prev_questions = self.questions_by_iteration.get(
- iteration - 1, []
- )
- source_count = len(self.all_search_results)
- prev_display = "\n".join(
- f"• {q}" for q in prev_questions[:3]
- )
- self._update_progress(
- f"Generating questions from {source_count} sources:\n{prev_display}",
- iteration_progress + 2,
- {
- "phase": "question_generation",
- "type": "milestone",
- "iteration": iteration,
- "source_count": source_count,
- },
- )
+ self._emit_question_generation_progress(
+ iteration=iteration,
+ progress_percent=iteration_progress + 2,
+ source_count=len(self.all_search_results)
+ if iteration > 1
+ else 0,
+ )
# Generate questions for this iteration
if self.use_browsecomp_optimization:
@@ -218,18 +197,10 @@ class FocusedIterationStrategy(BaseSearchStrategy):
logger.info(f"Iteration {iteration} questions: {questions}")
# Report starting searches with questions as milestone
- questions_display = "\n".join(f"• {q}" for q in questions[:5])
- if len(questions) > 5:
- questions_display += f"\n... and {len(questions) - 5} more"
- self._update_progress(
- f"Searching iteration {iteration}:\n{questions_display}",
- iteration_progress + 5,
- {
- "phase": f"iteration_{iteration}_searching",
- "type": "milestone",
- "iteration": iteration,
- "questions": questions,
- },
+ self._emit_searching_progress(
+ iteration=iteration,
+ questions=questions,
+ progress_percent=iteration_progress + 5,
)
# Execute searches
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 832041c65c..48ca3b9c0d 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
@@ -159,34 +159,13 @@ class SourceBasedSearchStrategy(BaseSearchStrategy):
# Step 1: Generate or use questions
# Show context-aware progress message
- if iteration == 1:
- self._update_progress(
- "Generating initial search questions...",
- iteration_progress_base + 5,
- {
- "phase": "question_generation",
- "iteration": iteration,
- },
- )
- else:
- # Show previous questions and source count
- prev_questions = self.questions_by_iteration.get(
- iteration - 1, []
- )
- source_count = len(filtered_search_results)
- prev_display = "\n".join(
- f"• {q}" for q in prev_questions[:3]
- )
- self._update_progress(
- f"Generating questions from {source_count} sources:\n{prev_display}",
- iteration_progress_base + 5,
- {
- "phase": "question_generation",
- "type": "milestone",
- "iteration": iteration,
- "source_count": source_count,
- },
- )
+ self._emit_question_generation_progress(
+ iteration=iteration,
+ progress_percent=iteration_progress_base + 5,
+ source_count=len(filtered_search_results)
+ if iteration > 1
+ else 0,
+ )
# For first iteration, use initial query
if iteration == 1:
@@ -285,23 +264,10 @@ class SourceBasedSearchStrategy(BaseSearchStrategy):
)
# Step 2: Run all searches in parallel for this iteration
- # Show the questions as a milestone while searching
- questions_display = "\n".join(
- f"• {q}" for q in all_questions[:5]
- )
- if len(all_questions) > 5:
- questions_display += (
- f"\n... and {len(all_questions) - 5} more"
- )
- self._update_progress(
- f"Searching iteration {iteration}:\n{questions_display}",
- iteration_progress_base + 10,
- {
- "phase": "parallel_search",
- "type": "milestone",
- "iteration": iteration,
- "questions": all_questions,
- },
+ self._emit_searching_progress(
+ iteration=iteration,
+ questions=all_questions,
+ progress_percent=iteration_progress_base + 10,
)
# Function for thread pool