~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: Replace all get_db_setting references with get_setting_from_db_main_thread in tests
LearningCircuit4188936646df
diff --git a/tests/auth_tests/conftest.py b/tests/auth_tests/conftest.pyindex a135c38787..7a8d563279 100644--- a/tests/auth_tests/conftest.py+++ b/tests/auth_tests/conftest.py@@ -49,4 +49,6 @@ def mock_settings(monkeypatch):import src.local_deep_research.utilities.db_utils as db_utils- monkeypatch.setattr(db_utils, "get_db_setting", mock_get_db_setting)+ monkeypatch.setattr(+ db_utils, "get_setting_from_db_main_thread", mock_get_db_setting+ )diff --git a/tests/conftest.py b/tests/conftest.pyindex 9adbfc079e..27c0ea53ff 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -135,8 +135,10 @@ def setup_database_for_all_tests(db_utils_module.get_db_session.cache_clear()if hasattr(db_utils_module.get_settings_manager, "cache_clear"):db_utils_module.get_settings_manager.cache_clear()- if hasattr(db_utils_module.get_db_setting, "cache_clear"):- db_utils_module.get_db_setting.cache_clear() # Clear get_db_setting's cache too+ if hasattr(+ db_utils_module.get_setting_from_db_main_thread, "cache_clear"+ ):+ db_utils_module.get_setting_from_db_main_thread.cache_clear() # Clear get_setting_from_db_main_thread's cache tooexcept Exception as e:print(f"ERROR: Failed to clear db_utils caches aggressively: {e}")diff --git a/tests/feature_tests/test_custom_context.py b/tests/feature_tests/test_custom_context.pyindex e7f707a4cc..4cadc3948d 100644--- a/tests/feature_tests/test_custom_context.py+++ b/tests/feature_tests/test_custom_context.py@@ -26,9 +26,11 @@ def patch_db_setting():This simulates what would happen if we added a context_window_size setting."""# Import here to avoid module level import issues- from local_deep_research.utilities.db_utils import get_db_setting+ from local_deep_research.utilities.db_utils import (+ get_setting_from_db_main_thread,+ )- original_get_db_setting = get_db_setting+ original_get_db_setting = get_setting_from_db_main_threadsettings_override = {"llm.context_window_size": 8192, # Custom context window size setting}@@ -42,14 +44,14 @@ def patch_db_setting():# Apply the patchimport local_deep_research.utilities.db_utils- local_deep_research.utilities.db_utils.get_db_setting = (+ local_deep_research.utilities.db_utils.get_setting_from_db_main_thread = (patched_get_db_setting)# Also patch the llm_config moduleimport local_deep_research.config.llm_config- local_deep_research.config.llm_config.get_db_setting = (+ local_deep_research.config.llm_config.get_setting_from_db_main_thread = (patched_get_db_setting)@@ -70,13 +72,17 @@ def modify_llm_creation(Dict containing configuration used"""# Import here to avoid module level import issues- from local_deep_research.utilities.db_utils import get_db_setting+ from local_deep_research.utilities.db_utils import (+ get_setting_from_db_main_thread,+ )# Get context window size from settings- context_window_size = get_db_setting("llm.context_window_size", 32000)+ context_window_size = get_setting_from_db_main_thread(+ "llm.context_window_size", 32000+ )# Get current max_tokens setting- max_tokens = get_db_setting("llm.max_tokens", 30000)+ max_tokens = get_setting_from_db_main_thread("llm.max_tokens", 30000)logger.info(f"Provider: {provider}")logger.info(f"Context window size from settings: {context_window_size}")diff --git a/tests/mock_modules.py b/tests/mock_modules.pyindex a732fe4ac1..9237c79446 100644--- a/tests/mock_modules.py+++ b/tests/mock_modules.py@@ -157,7 +157,9 @@ def create_mock_db_utils(if settings:default_settings.update(settings)- def get_db_setting(key: str, default=None):+ def get_setting_from_db_main_thread(+ key: str, default=None, username: str | None = None+ ):return default_settings.get(key, default)def get_db_session():@@ -171,11 +173,11 @@ def create_mock_db_utils(return mock_managerattributes = {- "get_db_setting": get_db_setting,+ "get_setting_from_db_main_thread": get_setting_from_db_main_thread,"get_db_session": get_db_session,"get_settings_manager": get_settings_manager,# Add cache_clear methods for compatibility- "get_db_setting.cache_clear": lambda: None,+ "get_setting_from_db_main_thread.cache_clear": lambda: None,"get_db_session.cache_clear": lambda: None,"get_settings_manager.cache_clear": lambda: None,}diff --git a/tests/rate_limiting/test_rate_limiting.py b/tests/rate_limiting/test_rate_limiting.pyindex 569d31b2e0..53d15a0d8c 100644--- a/tests/rate_limiting/test_rate_limiting.py+++ b/tests/rate_limiting/test_rate_limiting.py@@ -32,7 +32,7 @@ class TestAdaptiveRateLimitTracker(unittest.TestCase):# from the DB. This makes things more reliable.with patch("src.local_deep_research.web_search_engines.rate_limiting.tracker"- ".get_db_setting",+ ".get_setting_from_db_main_thread",side_effect=lambda key, default=None: default,):self.tracker = AdaptiveRateLimitTracker()diff --git a/tests/test_api_key_configuration.py b/tests/test_api_key_configuration.pyindex 0dc4ffdc26..088df7a81c 100644--- a/tests/test_api_key_configuration.py+++ b/tests/test_api_key_configuration.py@@ -291,7 +291,7 @@ class TestAPIKeyConfiguration:def test_api_availability_checks(self):"""Test the availability check functions for different providers."""with patch(- "local_deep_research.config.llm_config.get_db_setting"+ "local_deep_research.config.llm_config.get_setting_from_db_main_thread") as mock_get_db_setting:# Test OpenAI availabilitymock_get_db_setting.return_value = "test-openai-key"diff --git a/tests/test_citation_handler.py b/tests/test_citation_handler.pyindex ec4c9d5f5e..a39d7189a4 100644--- a/tests/test_citation_handler.py+++ b/tests/test_citation_handler.py@@ -144,7 +144,7 @@ def test_analyze_followup(citation_handler, sample_search_results, monkeypatch):return defaultmonkeypatch.setattr(- "src.local_deep_research.citation_handler.get_db_setting",+ "src.local_deep_research.citation_handler.get_setting_from_db_main_thread",mock_get_db_setting,)@@ -185,11 +185,11 @@ def test_analyze_followup_no_fact_check(# Patch in both locations where it might be importedmonkeypatch.setattr(- "src.local_deep_research.citation_handler.get_db_setting",+ "src.local_deep_research.citation_handler.get_setting_from_db_main_thread",mock_get_db_setting,)monkeypatch.setattr(- "src.local_deep_research.citation_handlers.standard_citation_handler.get_db_setting",+ "src.local_deep_research.citation_handlers.standard_citation_handler.get_setting_from_db_main_thread",mock_get_db_setting,)diff --git a/tests/test_llm_provider_integration.py b/tests/test_llm_provider_integration.pyindex 075bb3d8f8..716dc18544 100644--- a/tests/test_llm_provider_integration.py+++ b/tests/test_llm_provider_integration.py@@ -290,7 +290,7 @@ class TestLLMProviderIntegration:"llm.openai_endpoint.api_key", "sk-test-key")with patch(- "local_deep_research.config.llm_config.get_db_setting"+ "local_deep_research.config.llm_config.get_setting_from_db_main_thread") as mock_get_setting:mock_get_setting.return_value = "sk-test-key"assert is_openai_endpoint_available() is True@@ -298,7 +298,7 @@ class TestLLMProviderIntegration:# Without API keysettings_manager.set_setting("llm.openai_endpoint.api_key", None)with patch(- "local_deep_research.config.llm_config.get_db_setting"+ "local_deep_research.config.llm_config.get_setting_from_db_main_thread") as mock_get_setting:mock_get_setting.return_value = Noneassert is_openai_endpoint_available() is Falsediff --git a/tests/test_llm_rate_limiting.py b/tests/test_llm_rate_limiting.pyindex 4e20ad7108..4cbdcdaa4a 100644--- a/tests/test_llm_rate_limiting.py+++ b/tests/test_llm_rate_limiting.py@@ -84,7 +84,7 @@ class TestRateLimitedLLMWrapper:}with patch(- "local_deep_research.web_search_engines.rate_limiting.llm.wrapper.get_db_setting"+ "local_deep_research.web_search_engines.rate_limiting.llm.wrapper.get_setting_from_db_main_thread") as mock:mock.side_effect = lambda key, default=None: settings.get(key, default@@ -106,7 +106,7 @@ class TestRateLimitedLLMWrapper:def test_wrapper_creation_with_rate_limiting_disabled(self, mock_llm):"""Test wrapper creation when rate limiting is disabled."""with patch(- "local_deep_research.web_search_engines.rate_limiting.llm.wrapper.get_db_setting"+ "local_deep_research.web_search_engines.rate_limiting.llm.wrapper.get_setting_from_db_main_thread") as mock:mock.return_value = False # Rate limiting disabled@@ -140,7 +140,7 @@ class TestRateLimitedLLMWrapper:def test_invoke_without_rate_limiting(self, mock_llm):"""Test invoke when rate limiting is disabled."""with patch(- "local_deep_research.web_search_engines.rate_limiting.llm.wrapper.get_db_setting"+ "local_deep_research.web_search_engines.rate_limiting.llm.wrapper.get_setting_from_db_main_thread") as mock:mock.return_value = False # Rate limiting disabled@@ -212,7 +212,7 @@ class TestIntegrationWithTracker:"local_deep_research.web_search_engines.rate_limiting.llm.wrapper.get_tracker")@patch(- "local_deep_research.web_search_engines.rate_limiting.llm.wrapper.get_db_setting"+ "local_deep_research.web_search_engines.rate_limiting.llm.wrapper.get_setting_from_db_main_thread")def test_tracker_records_successful_attempt(self, mock_db_setting, mock_get_trackerdiff --git a/tests/test_search_system.py b/tests/test_search_system.pyindex 6bcd98af5c..df826c8e65 100644--- a/tests/test_search_system.py+++ b/tests/test_search_system.py@@ -293,7 +293,7 @@ def test_analyze_topic(monkeypatch):)# Mock get_db_setting for progress callbackmonkeypatch.setattr(- "local_deep_research.search_system.get_db_setting",+ "local_deep_research.search_system.get_setting_from_db_main_thread",lambda key, default=None: {"llm.provider": "test_provider","llm.model": "test_model",diff --git a/tests/text_optimization/test_integration.py b/tests/text_optimization/test_integration.pyindex 72f44555eb..f3e66393ac 100644--- a/tests/text_optimization/test_integration.py+++ b/tests/text_optimization/test_integration.py@@ -18,7 +18,9 @@ from local_deep_research.text_optimization import (class TestResearchServiceIntegration:"""Test integration of text optimization with research service."""- @patch("local_deep_research.config.search_config.get_db_setting")+ @patch(+ "local_deep_research.config.search_config.get_setting_from_db_main_thread"+ )def test_get_citation_formatter_number_mode(self, mock_get_setting):"""Test getting formatter with number hyperlinks mode."""mock_get_setting.return_value = "number_hyperlinks"@@ -27,7 +29,9 @@ class TestResearchServiceIntegration:assert isinstance(formatter, CitationFormatter)assert formatter.mode == CitationMode.NUMBER_HYPERLINKS- @patch("local_deep_research.config.search_config.get_db_setting")+ @patch(+ "local_deep_research.config.search_config.get_setting_from_db_main_thread"+ )def test_get_citation_formatter_domain_mode(self, mock_get_setting):"""Test getting formatter with domain hyperlinks mode."""mock_get_setting.return_value = "domain_hyperlinks"@@ -36,7 +40,9 @@ class TestResearchServiceIntegration:assert isinstance(formatter, CitationFormatter)assert formatter.mode == CitationMode.DOMAIN_HYPERLINKS- @patch("local_deep_research.config.search_config.get_db_setting")+ @patch(+ "local_deep_research.config.search_config.get_setting_from_db_main_thread"+ )def test_get_citation_formatter_no_hyperlinks_mode(self, mock_get_setting):"""Test getting formatter with no hyperlinks mode."""mock_get_setting.return_value = "no_hyperlinks"@@ -45,7 +51,9 @@ class TestResearchServiceIntegration:assert isinstance(formatter, CitationFormatter)assert formatter.mode == CitationMode.NO_HYPERLINKS- @patch("local_deep_research.config.search_config.get_db_setting")+ @patch(+ "local_deep_research.config.search_config.get_setting_from_db_main_thread"+ )def test_get_citation_formatter_invalid_mode(self, mock_get_setting):"""Test getting formatter with invalid mode falls back to default."""mock_get_setting.return_value = "invalid_mode"@@ -93,7 +101,9 @@ This is a test with citation [1].finally:markdown_path.unlink()- @patch("local_deep_research.config.search_config.get_db_setting")+ @patch(+ "local_deep_research.config.search_config.get_setting_from_db_main_thread"+ )def test_real_world_citation_formatting(self, mock_get_setting):"""Test citation formatting with real-world example."""mock_get_setting.return_value = "number_hyperlinks"@@ -246,7 +256,9 @@ This report discusses recent advances [1] and challenges [2].finally:markdown_path.unlink()- @patch("local_deep_research.config.search_config.get_db_setting")+ @patch(+ "local_deep_research.config.search_config.get_setting_from_db_main_thread"+ )def test_automatic_export_formats(self, mock_get_setting):"""Test automatic export to multiple formats based on settings."""# This would be called in the actual research service when saving reports