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.

fixed bug and some minor improvments

LearningCircuitf6592ad4beea
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 5e2f660fb5..a8233cd683 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
@@ -118,7 +118,7 @@ class SourceBasedSearchStrategy(BaseSearchStrategy):
# Determine number of iterations to run
iterations_to_run = get_db_setting("search.iterations")
- logger.debug("Selected amount of iterations: " + iterations_to_run)
+ logger.debug("Selected amount of iterations: " + str(iterations_to_run))
iterations_to_run = int(iterations_to_run)
try:
# Run each iteration
@@ -140,19 +140,41 @@ class SourceBasedSearchStrategy(BaseSearchStrategy):
# For first iteration, use initial query
if iteration == 1:
- # First round is simply the initial query
- all_questions = [query]
- self.questions_by_iteration[iteration] = [query]
+ # Generate questions for first iteration
+ source_context = self._format_search_results_as_context(
+ self.all_search_results
+ )
+ context = f"""Iteration: {iteration} of {iterations_to_run}"""
+ questions = self.question_generator.generate_questions(
+ current_knowledge=context,
+ query=query,
+ questions_per_iteration=int(
+ get_db_setting("search.questions_per_iteration")
+ ),
+ questions_by_iteration=self.questions_by_iteration,
+ )
+
+ # Always include the original query for the first iteration
+ if query not in questions:
+ all_questions = [query] + questions
+ else:
+ all_questions = questions
+
+ self.questions_by_iteration[iteration] = all_questions
logger.info(
- f"Using initial query for iteration {iteration}: {query}"
+ f"Using questions for iteration {iteration}: {all_questions}"
)
else:
# For subsequent iterations, generate questions based on previous search results
source_context = self._format_search_results_as_context(
self.all_search_results
)
- context = f"""Previous search results:\n{source_context}\n\nIteration: {iteration} of {iterations_to_run}"""
-
+ if iteration != 1:
+ context = f"""Previous search results:\n{source_context}\n\nIteration: {iteration} of {iterations_to_run}"""
+ elif iterations_to_run == 1:
+ context = ""
+ else:
+ context = f"""Iteration: {iteration} of {iterations_to_run}"""
# Use standard question generator with search results as context
questions = self.question_generator.generate_questions(
current_knowledge=context,
diff --git a/src/local_deep_research/web/services/research_service.py b/src/local_deep_research/web/services/research_service.py
index c326813046..6ca46fc73b 100644
--- a/src/local_deep_research/web/services/research_service.py
+++ b/src/local_deep_research/web/services/research_service.py
@@ -690,6 +690,10 @@ def run_research_process(
# Handle error
error_message = f"Research failed: {str(e)}"
logger.error(error_message)
+ import traceback
+
+ logger.error("Exception occurred:" + str(traceback.print_exc()))
+
try:
# Check for common Ollama error patterns in the exception and provide more user-friendly errors
user_friendly_error = str(e)