~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
multiple bugfixes
LearningCircuitcb322a4f2544
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.pyindex a8233cd683..98a7ff4806 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@@ -37,8 +37,7 @@ class SourceBasedSearchStrategy(BaseSearchStrategy):self.search = search or get_search()self.model = model or get_llm()self.progress_callback = None- self.all_links_of_system = list()- self.all_search_results = []+self.questions_by_iteration = {}self.include_text_content = include_text_contentself.use_cross_engine_filter = use_cross_engine_filter@@ -87,13 +86,11 @@ class SourceBasedSearchStrategy(BaseSearchStrategy):Analyze a topic using source-based search strategy."""logger.info(f"Starting source-based research on topic: {query}")-+ accumulated_search_results_across_all_iterations = (+ []+ ) # tracking links across iterations but not globalfindings = []- self.all_search_results = []-- # Track all search results across iterations- self.all_links_of_system = list()- self.questions_by_iteration = {}+ total_citation_count_before_this_search = len(self.all_links_of_system)self._update_progress("Initializing source-based research",@@ -141,9 +138,6 @@ class SourceBasedSearchStrategy(BaseSearchStrategy):# For first iteration, use initial queryif iteration == 1:# 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,@@ -167,7 +161,7 @@ class SourceBasedSearchStrategy(BaseSearchStrategy):else:# For subsequent iterations, generate questions based on previous search resultssource_context = self._format_search_results_as_context(- self.all_search_results+ self.all_links_of_system)if iteration != 1:context = f"""Previous search results:\n{source_context}\n\nIteration: {iteration} of {iterations_to_run}"""@@ -246,7 +240,7 @@ class SourceBasedSearchStrategy(BaseSearchStrategy):iteration_search_results.extend(search_results)# Step 3: Apply cross-engine filtering if enabled- if self.use_cross_engine_filter:+ if False and self.use_cross_engine_filter:self._update_progress(f"Filtering search results for iteration {iteration}",iteration_progress_base + 45,@@ -255,19 +249,16 @@ class SourceBasedSearchStrategy(BaseSearchStrategy):# Get the current link count (for indexing)existing_link_count = len(self.all_links_of_system)-+ logger.info(f"Existing link count: {existing_link_count}")# Filter the search resultsfiltered_search_results = self.cross_engine_filter.filter_results(iteration_search_results,query,- reorder=self.filter_reorder,- reindex=self.filter_reindex,+ reorder=True,+ reindex=True,start_index=existing_link_count, # Start indexing after existing links)- links = extract_links_from_search_results(filtered_search_results)- self.all_links_of_system.extend(links)-self._update_progress(f"Filtered from {len(iteration_search_results)} to {len(filtered_search_results)} results",iteration_progress_base + 50,@@ -279,14 +270,11 @@ class SourceBasedSearchStrategy(BaseSearchStrategy):)# Use filtered results- iteration_search_results = filtered_search_results- else:- # Just extract links without filtering- links = extract_links_from_search_results(iteration_search_results)- self.all_links_of_system.extend(links)-- # Add to all search results- self.all_search_results.extend(iteration_search_results)+ accumulated_search_results_across_all_iterations.extend(+ self.all_links_of_system+ )+ links = extract_links_from_search_results(iteration_search_results)+ self.all_links_of_system.extend(links)# Create a lightweight finding for this iteration's search metadata (no text content)finding = {@@ -306,46 +294,43 @@ class SourceBasedSearchStrategy(BaseSearchStrategy):{"phase": "iteration_complete", "iteration": iteration},)- # Final filtering of all accumulated search results- self._update_progress(- "Performing final filtering of all results",- 80,- {"phase": "final_filtering"},- )-- # Apply final cross-engine filtering to all accumulated results if enabled- if self.use_cross_engine_filter:+ # Do we need this filter?+ if False and self.use_cross_engine_filter and iterations_to_run > 1:+ # Final filtering of all accumulated search results+ self._update_progress(+ "Performing final filtering of all results",+ 80,+ {"phase": "final_filtering"},+ )final_filtered_results = self.cross_engine_filter.filter_results(- self.all_search_results,+ accumulated_search_results_across_all_iterations,query,reorder=True, # Always reorder in final filtering- reindex=False, # Always reindex in final filtering- max_results=int(get_db_setting("search.final_max_results") or 30),+ reindex=True, # Always reindex in final filtering+ max_results=int(get_db_setting("search.final_max_results") or 100),+ start_index=len(self.all_links_of_system),)- else:- final_filtered_results = self.all_search_results- self._update_progress(- f"Filtered from {len(self.all_search_results)} to {len(final_filtered_results)} results",- iteration_progress_base + 85,- {- "phase": "filtering_complete",- "iteration": iteration,- "links_count": len(self.all_links_of_system),- },- )+ self._update_progress(+ f"Filtered from {len(accumulated_search_results_across_all_iterations)} to {len(final_filtered_results)} results",+ iteration_progress_base + 85,+ {+ "phase": "filtering_complete",+ "iteration": iteration,+ "links_count": len(self.all_links_of_system),+ },+ )+# Final synthesis after all iterationsself._update_progress("Generating final synthesis", 90, {"phase": "synthesis"})- total_citation_count = len(self.all_links_of_system)-# Final synthesisfinal_citation_result = self.citation_handler.analyze_followup(query,- final_filtered_results,+ self.all_links_of_system,previous_knowledge="", # Empty string as we don't need previous knowledge here- nr_of_links=total_citation_count,+ nr_of_links=total_citation_count_before_this_search,)# Add null check for final_citation_result@@ -361,7 +346,7 @@ class SourceBasedSearchStrategy(BaseSearchStrategy):"phase": "Final synthesis","content": synthesized_content,"question": query,- "search_results": final_filtered_results,+ "search_results": self.all_links_of_system,"documents": documents,}findings.append(final_finding)@@ -404,4 +389,5 @@ class SourceBasedSearchStrategy(BaseSearchStrategy):"questions_by_iteration": self.questions_by_iteration,"formatted_findings": formatted_findings,"current_knowledge": synthesized_content,+ "all_links_of_system": self.all_links_of_system,}diff --git a/src/local_deep_research/config/llm_config.py b/src/local_deep_research/config/llm_config.pyindex a5e5ebed02..4e85f85fad 100644--- a/src/local_deep_research/config/llm_config.py+++ b/src/local_deep_research/config/llm_config.py@@ -131,7 +131,7 @@ def get_llm(model_name=None, temperature=None, provider=None, openai_endpoint_urreturn get_fallback_model(temperature)# Get endpoint URL from settings- if openai_endpoint_url is not None:+ if openai_endpoint_url is None:openai_endpoint_url = get_db_setting("llm.openai_endpoint_url", settings.llm.openai_endpoint_url)diff --git a/src/local_deep_research/defaults/main.toml b/src/local_deep_research/defaults/main.tomlindex f9024052d5..5ef97a9558 100644--- a/src/local_deep_research/defaults/main.toml+++ b/src/local_deep_research/defaults/main.toml@@ -44,13 +44,13 @@ enable_fact_checking = falsetool = "auto"# Number of research cycles-iterations = 2+iterations = 1# Questions generated per cycle-questions_per_iteration = 2+questions_per_iteration = 3# Searches per report section-searches_per_section = 2+searches_per_section = 1# Results per search querymax_results = 50diff --git a/src/local_deep_research/search_system.py b/src/local_deep_research/search_system.pyindex 7e520df197..02b875fc29 100644--- a/src/local_deep_research/search_system.py+++ b/src/local_deep_research/search_system.py@@ -74,6 +74,10 @@ class AdvancedSearchSystem:self.citation_handler = CitationHandler(self.model)self.question_generator = StandardQuestionGenerator(self.model)self.findings_repository = FindingsRepository(self.model)+ # For backward compatibility+ self.questions_by_iteration = list()+ self.progress_callback = lambda _1, _2, _3: None+ self.all_links_of_system = list()# Initialize strategy based on nameif strategy_name.lower() == "iterdrag":@@ -105,11 +109,6 @@ class AdvancedSearchSystem:# Log the actual strategy classlogger.info(f"Created strategy of type: {type(self.strategy).__name__}")- # For backward compatibility- self.questions_by_iteration = {}- self.progress_callback = lambda _1, _2, _3: None- self.all_links_of_system = list()-# Configure the strategy with our attributesif hasattr(self, "progress_callback") and self.progress_callback:self.strategy.set_progress_callback(self.progress_callback)@@ -163,25 +162,15 @@ class AdvancedSearchSystem:result = self.strategy.analyze_topic(query)# Update our attributes for backward compatibility- if hasattr(self.strategy, "questions_by_iteration"):- self.questions_by_iteration = self.strategy.questions_by_iteration- # Send progress message with search info- self.progress_callback(- f"Processed questions: {self.strategy.questions_by_iteration}",- 2, # Low percentage to show this as an early step- {- "phase": "setup",- "search_info": {- "questions_by_iteration": len(- self.strategy.questions_by_iteration- )- },- },- )- if hasattr(self.strategy, "all_links_of_system"):- self.all_links_of_system = self.strategy.all_links_of_system++ self.questions_by_iteration = self.strategy.questions_by_iteration.copy()+ # Send progress message with search info++ # if hasattr(self.strategy, "all_links_of_system"):+ self.all_links_of_system.extend(self.strategy.all_links_of_system)# Include the search system instance for access to citationsresult["search_system"] = self-+ result["all_links_of_system"] = self.all_links_of_system+ result["questions_by_iteration"] = self.questions_by_iterationreturn resultdiff --git a/src/local_deep_research/utilities/search_utilities.py b/src/local_deep_research/utilities/search_utilities.pyindex a3604bb1f4..7c1b82f3e0 100644--- a/src/local_deep_research/utilities/search_utilities.py+++ b/src/local_deep_research/utilities/search_utilities.py@@ -50,6 +50,7 @@ def format_links(links: List[Dict]) -> str:def format_links_to_markdown(all_links: List[Dict]) -> str:formatted_text = ""+ logger.info(f"Formatting {len(all_links)} links to markdown...")if all_links:# Group links by URL and collect all their indices