~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
refactor: Address code review feedback from bots
LearningCircuit8360ae9602b4
diff --git a/src/local_deep_research/advanced_search_system/strategies/iterative_refinement_strategy.py b/src/local_deep_research/advanced_search_system/strategies/iterative_refinement_strategy.pyindex b9eb04f44a..582a238875 100644--- a/src/local_deep_research/advanced_search_system/strategies/iterative_refinement_strategy.py+++ b/src/local_deep_research/advanced_search_system/strategies/iterative_refinement_strategy.py@@ -10,7 +10,7 @@ This strategy orchestrates iterative refinement of research results by:"""import json-from typing import Dict+from typing import Dict, Optionalfrom loguru import loggerfrom .base_strategy import BaseSearchStrategy@@ -41,6 +41,7 @@ class IterativeRefinementStrategy(BaseSearchStrategy):evaluation_frequency: int = 1,max_refinements: int = 3,confidence_threshold: float = 0.8,+ max_evaluation_tokens: Optional[int] = None, # None = no truncation**kwargs,):"""@@ -55,15 +56,27 @@ class IterativeRefinementStrategy(BaseSearchStrategy):evaluation_frequency: Evaluate after N refinement rounds (1 = every round)max_refinements: Maximum number of refinement cyclesconfidence_threshold: Confidence level to stop refinement (0.0-1.0)+ max_evaluation_tokens: Maximum tokens for LLM evaluation (None = no truncation)"""super().__init__(all_links_of_system, settings_snapshot)+ # Validate parameters+ if not 0 <= confidence_threshold <= 1:+ raise ValueError("confidence_threshold must be between 0 and 1")+ if max_refinements < 0:+ raise ValueError("max_refinements must be non-negative")+ if evaluation_frequency < 1:+ raise ValueError("evaluation_frequency must be at least 1")+ if max_evaluation_tokens is not None and max_evaluation_tokens <= 0:+ raise ValueError("max_evaluation_tokens must be positive or None")+self.model = modelself.search = searchself.initial_strategy = initial_strategyself.evaluation_frequency = evaluation_frequencyself.max_refinements = max_refinementsself.confidence_threshold = confidence_threshold+ self.max_evaluation_tokens = max_evaluation_tokens# Track refinement historyself.refinement_history = []@@ -250,15 +263,14 @@ class IterativeRefinementStrategy(BaseSearchStrategy):# Re-raise to see the actual errorraise- # Update accumulated sources+ # Update accumulated sources (O(1) lookup with set)+ existing_urls = {s.get("url") for s in all_accumulated_sources}new_sources = followup_results.get("all_links_of_system", [])for source in new_sources:# Check if URL already exists to avoid duplicates- if not any(- s.get("url") == source.get("url")- for s in all_accumulated_sources- ):+ if source.get("url") not in existing_urls:all_accumulated_sources.append(source)+ existing_urls.add(source.get("url"))# Update research context for next iterationresearch_context = self._build_research_context(results, query)@@ -400,7 +412,7 @@ Original Research Query: {original_query}Current Refinement Iteration: {iteration + 1} of {self.max_refinements}Current Research Findings:-{findings[:3000]} # Truncate for token limits+{findings if self.max_evaluation_tokens is None else findings[: self.max_evaluation_tokens]}Number of sources found: {sources_count}Previous gaps identified: {", ".join(previous_gaps) if previous_gaps else "None"}