~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
fix: Fix test failures in programmatic access PR
LearningCircuit67cb51918322
diff --git a/src/local_deep_research/database/models/metrics.py b/src/local_deep_research/database/models/metrics.pyindex 5b169cc942..cfd5f5af07 100644--- a/src/local_deep_research/database/models/metrics.py+++ b/src/local_deep_research/database/models/metrics.py@@ -85,7 +85,7 @@ class ModelUsage(Base):# Time trackingfirst_used_at = Column(UtcDateTime, default=utcnow())- last_used_at = Column(UtcDateTime, default=utcnow(), onupdate=utcnow)+ last_used_at = Column(UtcDateTime, default=utcnow(), onupdate=utcnow())def __repr__(self):return f"<ModelUsage(model={self.model_name}, calls={self.total_calls}, cost=${self.total_cost:.2f})>"@@ -115,7 +115,7 @@ class ResearchRating(Base):# Timestampscreated_at = Column(UtcDateTime, default=utcnow())- updated_at = Column(UtcDateTime, default=utcnow(), onupdate=utcnow)+ updated_at = Column(UtcDateTime, default=utcnow(), onupdate=utcnow())def __repr__(self):return f"<ResearchRating(research_id={self.research_id}, rating={self.rating})>"diff --git a/src/local_deep_research/database/models/news.py b/src/local_deep_research/database/models/news.pyindex 9fdb1c220f..48eb4eebce 100644--- a/src/local_deep_research/database/models/news.py+++ b/src/local_deep_research/database/models/news.py@@ -76,7 +76,7 @@ class NewsSubscription(Base):updated_at = Column(UtcDateTime,default=utcnow(),- onupdate=utcnow,+ onupdate=utcnow(),)last_refresh = Column(UtcDateTime)next_refresh = Column(UtcDateTime)@@ -133,7 +133,7 @@ class SubscriptionFolder(Base):updated_at = Column(UtcDateTime,default=utcnow(),- onupdate=utcnow,+ onupdate=utcnow(),)# Settings@@ -219,7 +219,7 @@ class UserPreference(Base):updated_at = Column(UtcDateTime,default=utcnow(),- onupdate=utcnow,+ onupdate=utcnow(),)diff --git a/src/local_deep_research/database/models/queue.py b/src/local_deep_research/database/models/queue.pyindex e0977d8405..e9f79399f5 100644--- a/src/local_deep_research/database/models/queue.py+++ b/src/local_deep_research/database/models/queue.py@@ -18,7 +18,7 @@ class QueueStatus(Base):queued_tasks = Column(Integer, default=0)last_checked = Column(UtcDateTime, default=utcnow())last_task_id = Column(String, nullable=True)- updated_at = Column(UtcDateTime, default=utcnow(), onupdate=utcnow)+ updated_at = Column(UtcDateTime, default=utcnow(), onupdate=utcnow())class TaskMetadata(Base):diff --git a/src/local_deep_research/database/models/rate_limiting.py b/src/local_deep_research/database/models/rate_limiting.pyindex 06fcf5d5ec..05c6580574 100644--- a/src/local_deep_research/database/models/rate_limiting.py+++ b/src/local_deep_research/database/models/rate_limiting.py@@ -45,7 +45,7 @@ class RateLimitEstimate(Base):success_rate = Column(Float, default=0.0, nullable=False)created_at = Column(UtcDateTime, server_default=utcnow(), nullable=False)updated_at = Column(- UtcDateTime, server_default=utcnow(), onupdate=utcnow, nullable=False+ UtcDateTime, server_default=utcnow(), onupdate=utcnow(), nullable=False)def __repr__(self):diff --git a/src/local_deep_research/database/models/reports.py b/src/local_deep_research/database/models/reports.pyindex 6f598105a0..e04c114d71 100644--- a/src/local_deep_research/database/models/reports.py+++ b/src/local_deep_research/database/models/reports.py@@ -60,7 +60,7 @@ class Report(Base):# Timestampscreated_at = Column(UtcDateTime, default=utcnow())- updated_at = Column(UtcDateTime, default=utcnow(), onupdate=utcnow)+ updated_at = Column(UtcDateTime, default=utcnow(), onupdate=utcnow())published_at = Column(UtcDateTime)# Relationships@@ -112,7 +112,7 @@ class ReportSection(Base):# Timestampscreated_at = Column(UtcDateTime, default=utcnow())- updated_at = Column(UtcDateTime, default=utcnow(), onupdate=utcnow)+ updated_at = Column(UtcDateTime, default=utcnow(), onupdate=utcnow())# Relationshipsreport = relationship("Report", back_populates="sections")diff --git a/src/local_deep_research/database/models/research.py b/src/local_deep_research/database/models/research.pyindex 1c1600f556..d33de29eba 100644--- a/src/local_deep_research/database/models/research.py+++ b/src/local_deep_research/database/models/research.py@@ -41,7 +41,7 @@ class ResearchTask(Base):# Timestampscreated_at = Column(UtcDateTime, default=utcnow())- updated_at = Column(UtcDateTime, default=utcnow(), onupdate=utcnow)+ updated_at = Column(UtcDateTime, default=utcnow(), onupdate=utcnow())started_at = Column(UtcDateTime)completed_at = Column(UtcDateTime)@@ -274,7 +274,7 @@ class Research(Base):)created_at = Column(UtcDateTime, server_default=utcnow(), nullable=False)updated_at = Column(- UtcDateTime, server_default=utcnow(), onupdate=utcnow, nullable=False+ UtcDateTime, server_default=utcnow(), onupdate=utcnow(), nullable=False)progress = Column(Float, default=0.0, nullable=False)start_time = Column(UtcDateTime, nullable=True)diff --git a/src/local_deep_research/database/models/settings.py b/src/local_deep_research/database/models/settings.pyindex c8955eb06b..1f892f49d8 100644--- a/src/local_deep_research/database/models/settings.py+++ b/src/local_deep_research/database/models/settings.py@@ -35,7 +35,7 @@ class UserSettings(Base):category = Column(String(100))description = Column(Text)created_at = Column(UtcDateTime, default=utcnow())- updated_at = Column(UtcDateTime, default=utcnow(), onupdate=utcnow)+ updated_at = Column(UtcDateTime, default=utcnow(), onupdate=utcnow())def __repr__(self):return f"<UserSettings(key='{self.key}', category='{self.category}')>"@@ -55,7 +55,7 @@ class APIKey(Base):description = Column(Text)is_active = Column(Boolean, default=True)created_at = Column(UtcDateTime, default=utcnow())- updated_at = Column(UtcDateTime, default=utcnow(), onupdate=utcnow)+ updated_at = Column(UtcDateTime, default=utcnow(), onupdate=utcnow())last_used = Column(UtcDateTime)usage_count = Column(Integer, default=0)@@ -99,7 +99,7 @@ class Setting(Base):env_var = Column(String(255), nullable=True) # Environment variable namecreated_at = Column(UtcDateTime, server_default=utcnow(), nullable=False)updated_at = Column(- UtcDateTime, server_default=utcnow(), onupdate=utcnow, nullable=False+ UtcDateTime, server_default=utcnow(), onupdate=utcnow(), nullable=False)__table_args__ = (UniqueConstraint("key", name="uix_settings_key"),)diff --git a/tests/test_llm_provider_integration.py b/tests/test_llm_provider_integration.pyindex 821f9672e1..ed76a50a46 100644--- a/tests/test_llm_provider_integration.py+++ b/tests/test_llm_provider_integration.py@@ -30,6 +30,7 @@ class TestLLMProviderIntegration:"search.tool": "searxng","search.iterations": 5,"search.questions_per_iteration": 3,+ "search.max_results": 10,"search.enable_direct_summary": True,"search.enable_search_engine": True,"search.additional_results": 3,diff --git a/tests/test_programmatic_custom_llm_retriever.py b/tests/test_programmatic_custom_llm_retriever.pyindex b54e26106e..d6fbbc69d8 100644--- a/tests/test_programmatic_custom_llm_retriever.py+++ b/tests/test_programmatic_custom_llm_retriever.py@@ -2,6 +2,7 @@import pytestfrom unittest.mock import patch, MagicMock+import requestsfrom langchain_community.llms import Ollamafrom langchain_community.embeddings import OllamaEmbeddingsfrom langchain_community.vectorstores import FAISS@@ -15,6 +16,15 @@ from src.local_deep_research.api import (from src.local_deep_research.llm import clear_llm_registry+def _is_ollama_running():+ """Check if Ollama service is running."""+ try:+ response = requests.get("http://localhost:11434/api/tags", timeout=1)+ return response.status_code == 200+ except:+ return False++@pytest.fixture(autouse=True)def clear_registries():"""Clear registries before and after each test."""@@ -107,6 +117,10 @@ def mock_search_system():return system+ not _is_ollama_running(),+ reason="Ollama is not running - skipping integration test",+)def test_quick_summary_with_ollama_and_memory_retriever(ollama_llm, memory_retriever, mock_search_system):@@ -143,6 +157,10 @@ def test_quick_summary_with_ollama_and_memory_retriever(assert init_kwargs["temperature"] == 0.5+ not _is_ollama_running(),+ reason="Ollama is not running - skipping integration test",+)def test_detailed_research_with_ollama_and_memory_retriever(ollama_llm, memory_retriever, mock_search_system):@@ -176,6 +194,10 @@ def test_detailed_research_with_ollama_and_memory_retriever(assert result["metadata"]["search_tool"] == "local_docs"+ not _is_ollama_running(),+ reason="Ollama is not running - skipping integration test",+)def test_generate_report_with_ollama_and_memory_retriever(ollama_llm, memory_retriever):@@ -225,6 +247,10 @@ def test_generate_report_with_ollama_and_memory_retriever(assert init_kwargs["search_tool"] == "vector_store"+ not _is_ollama_running(),+ reason="Ollama is not running - skipping integration test",+)def test_custom_vector_store_with_more_documents():"""Test creating a larger in-memory vector store."""@@ -291,6 +317,10 @@ def test_custom_vector_store_with_more_documents():assert result["summary"] == "Extended document analysis complete"+ not _is_ollama_running(),+ reason="Ollama is not running - skipping integration test",+)def test_multiple_retrievers_with_ollama():"""Test using multiple in-memory retrievers with Ollama."""@@ -351,6 +381,10 @@ def test_multiple_retrievers_with_ollama():assert "multiple vector stores" in result["summary"]+ not _is_ollama_running(),+ reason="Ollama is not running - skipping integration test",+)def test_simple_ollama_factory_pattern():"""Test using a factory function to create Ollama instances."""diff --git a/tests/test_search_system.py b/tests/test_search_system.pyindex b6a222acc1..ce62fc1382 100644--- a/tests/test_search_system.py+++ b/tests/test_search_system.py@@ -55,11 +55,13 @@ def test_progress_callback_forwarding(monkeypatch, mock_search, mock_llm):"local_deep_research.search_system.SourceBasedSearchStrategy",mock_strategy_class,)+ # Mock get_llm and get_search from their actual modulesmonkeypatch.setattr(- "local_deep_research.search_system.get_llm", lambda **kwargs: mock_llm+ "local_deep_research.config.llm_config.get_llm",+ lambda **kwargs: mock_llm,)monkeypatch.setattr(- "local_deep_research.search_system.get_search",+ "local_deep_research.web_search_engines.search_aggregator.get_search",lambda llm_instance=None, **kwargs: mock_search,)@@ -67,7 +69,7 @@ def test_progress_callback_forwarding(monkeypatch, mock_search, mock_llm):from local_deep_research.search_system import AdvancedSearchSystem# Create the search system (will use default source-based strategy)- system = AdvancedSearchSystem()+ system = AdvancedSearchSystem(llm=mock_llm, search=mock_search)# Create a mock progress callbackmock_callback = Mock()@@ -90,12 +92,13 @@ def test_init_source_based_strategy(monkeypatch):mock_llm_instance = Mock()mock_search_instance = Mock()+ # Mock get_llm and get_search from their actual modulesmonkeypatch.setattr(- "local_deep_research.search_system.get_llm",+ "local_deep_research.config.llm_config.get_llm",lambda **kwargs: mock_llm_instance,)monkeypatch.setattr(- "local_deep_research.search_system.get_search",+ "local_deep_research.web_search_engines.search_aggregator.get_search",lambda llm_instance=None, **kwargs: mock_search_instance,)@@ -110,14 +113,21 @@ def test_init_source_based_strategy(monkeypatch):}# Create with default strategy (source-based)- system = AdvancedSearchSystem(settings_snapshot=settings_snapshot)+ system = AdvancedSearchSystem(+ llm=mock_llm_instance,+ search=mock_search_instance,+ settings_snapshot=settings_snapshot,+ )# Check if the correct strategy type was createdassert "SourceBasedSearchStrategy" in system.strategy.__class__.__name__# Also test explicit source-based strategysystem_explicit = AdvancedSearchSystem(- strategy_name="source-based", settings_snapshot=settings_snapshot+ llm=mock_llm_instance,+ search=mock_search_instance,+ strategy_name="source-based",+ settings_snapshot=settings_snapshot,)assert ("SourceBasedSearchStrategy"@@ -131,12 +141,13 @@ def test_init_iterdrag_strategy(monkeypatch):mock_llm_instance = Mock()mock_search_instance = Mock()+ # Mock get_llm and get_search from their actual modulesmonkeypatch.setattr(- "local_deep_research.search_system.get_llm",+ "local_deep_research.config.llm_config.get_llm",lambda **kwargs: mock_llm_instance,)monkeypatch.setattr(- "local_deep_research.search_system.get_search",+ "local_deep_research.web_search_engines.search_aggregator.get_search",lambda llm_instance=None, **kwargs: mock_search_instance,)@@ -144,7 +155,11 @@ def test_init_iterdrag_strategy(monkeypatch):from local_deep_research.search_system import AdvancedSearchSystem# Create with IterDRAG strategy- system = AdvancedSearchSystem(strategy_name="iterdrag")+ system = AdvancedSearchSystem(+ llm=mock_llm_instance,+ search=mock_search_instance,+ strategy_name="iterdrag",+ )# Check if the correct strategy type was createdassert "IterDRAGStrategy" in system.strategy.__class__.__name__@@ -156,12 +171,13 @@ def test_init_parallel_strategy(monkeypatch):mock_llm_instance = Mock()mock_search_instance = Mock()+ # Mock get_llm and get_search from their actual modulesmonkeypatch.setattr(- "local_deep_research.search_system.get_llm",+ "local_deep_research.config.llm_config.get_llm",lambda **kwargs: mock_llm_instance,)monkeypatch.setattr(- "local_deep_research.search_system.get_search",+ "local_deep_research.web_search_engines.search_aggregator.get_search",lambda llm_instance=None, **kwargs: mock_search_instance,)@@ -177,7 +193,10 @@ def test_init_parallel_strategy(monkeypatch):# Create with parallel strategysystem = AdvancedSearchSystem(- strategy_name="parallel", settings_snapshot=settings_snapshot+ llm=mock_llm_instance,+ search=mock_search_instance,+ strategy_name="parallel",+ settings_snapshot=settings_snapshot,)# Check if the correct strategy type was created@@ -190,12 +209,13 @@ def test_init_rapid_strategy(monkeypatch):mock_llm_instance = Mock()mock_search_instance = Mock()+ # Mock get_llm and get_search from their actual modulesmonkeypatch.setattr(- "local_deep_research.search_system.get_llm",+ "local_deep_research.config.llm_config.get_llm",lambda **kwargs: mock_llm_instance,)monkeypatch.setattr(- "local_deep_research.search_system.get_search",+ "local_deep_research.web_search_engines.search_aggregator.get_search",lambda llm_instance=None, **kwargs: mock_search_instance,)@@ -203,7 +223,11 @@ def test_init_rapid_strategy(monkeypatch):from local_deep_research.search_system import AdvancedSearchSystem# Create with rapid strategy- system = AdvancedSearchSystem(strategy_name="rapid")+ system = AdvancedSearchSystem(+ llm=mock_llm_instance,+ search=mock_search_instance,+ strategy_name="rapid",+ )# Check if the correct strategy type was createdassert "RapidSearchStrategy" in system.strategy.__class__.__name__@@ -215,12 +239,13 @@ def test_init_invalid_strategy(monkeypatch):mock_llm_instance = Mock()mock_search_instance = Mock()+ # Mock get_llm and get_search from their actual modulesmonkeypatch.setattr(- "local_deep_research.search_system.get_llm",+ "local_deep_research.config.llm_config.get_llm",lambda **kwargs: mock_llm_instance,)monkeypatch.setattr(- "local_deep_research.search_system.get_search",+ "local_deep_research.web_search_engines.search_aggregator.get_search",lambda llm_instance=None, **kwargs: mock_search_instance,)@@ -242,12 +267,13 @@ def test_set_progress_callback(monkeypatch):mock_llm_instance = Mock()mock_search_instance = Mock()+ # Mock get_llm and get_search from their actual modulesmonkeypatch.setattr(- "local_deep_research.search_system.get_llm",+ "local_deep_research.config.llm_config.get_llm",lambda **kwargs: mock_llm_instance,)monkeypatch.setattr(- "local_deep_research.search_system.get_search",+ "local_deep_research.web_search_engines.search_aggregator.get_search",lambda llm_instance=None, **kwargs: mock_search_instance,)@@ -261,7 +287,11 @@ def test_set_progress_callback(monkeypatch):"search.cross_engine_min_date": {"value": None, "type": "str"},}- system = AdvancedSearchSystem(settings_snapshot=settings_snapshot)+ system = AdvancedSearchSystem(+ llm=mock_llm_instance,+ search=mock_search_instance,+ settings_snapshot=settings_snapshot,+ )# Create a mock callbackmock_callback = Mock()@@ -310,12 +340,13 @@ def test_analyze_topic(monkeypatch):]mock_strategy_class.return_value = mock_strategy_instance+ # Mock get_llm and get_search from their actual modulesmonkeypatch.setattr(- "local_deep_research.search_system.get_llm",+ "local_deep_research.config.llm_config.get_llm",lambda **kwargs: mock_llm_instance,)monkeypatch.setattr(- "local_deep_research.search_system.get_search",+ "local_deep_research.web_search_engines.search_aggregator.get_search",lambda llm_instance=None, **kwargs: mock_search_instance,)# Mock SourceBasedSearchStrategy which is now the default@@ -337,7 +368,11 @@ def test_analyze_topic(monkeypatch):}# Create the search system (uses source-based strategy by default)- system = AdvancedSearchSystem(settings_snapshot=settings_snapshot)+ system = AdvancedSearchSystem(+ llm=mock_llm_instance,+ search=mock_search_instance,+ settings_snapshot=settings_snapshot,+ )# Set mock all_links_of_system attribute on the strategysystem.strategy.all_links_of_system = [