~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(history): pass username explicitly to get_research_strategy (#4526)
LearningCircuit36d1a5819d95
diff --git a/src/local_deep_research/web/routes/history_routes.py b/src/local_deep_research/web/routes/history_routes.pyindex f0d06228b3..dce40da4ac 100644--- a/src/local_deep_research/web/routes/history_routes.py+++ b/src/local_deep_research/web/routes/history_routes.py@@ -230,7 +230,7 @@ def get_research_details(research_id):logs = get_logs_for_research(research_id)# Get strategy information- strategy_name = get_research_strategy(research_id)+ strategy_name = get_research_strategy(research_id, username=username)# Get an atomic snapshot of active research statesnapshot = get_active_research_snapshot(research_id)diff --git a/src/local_deep_research/web/services/research_service.py b/src/local_deep_research/web/services/research_service.pyindex 7e322875a7..687b489092 100644--- a/src/local_deep_research/web/services/research_service.py+++ b/src/local_deep_research/web/services/research_service.py@@ -242,14 +242,17 @@ def export_report_to_memory(return result.content, result.filename, result.mimetype-def save_research_strategy(research_id, strategy_name, username=None):+def save_research_strategy(research_id, strategy_name, *, username):"""Save the strategy used for a research to the database.Args:research_id: The ID of the researchstrategy_name: The name of the strategy used- username: The username for database access (required for thread context)+ username: The username whose encrypted DB to write. Required —+ without it get_user_db_session would silently fall back to+ the Flask session user (or fail off-request-context), so+ callers must state whose DB they mean."""try:logger.debug(@@ -287,13 +290,17 @@ def save_research_strategy(research_id, strategy_name, username=None):logger.exception("Error saving research strategy")-def get_research_strategy(research_id, username=None):+def get_research_strategy(research_id, *, username):"""Get the strategy used for a research.Args:research_id: The ID of the research- username: The username for database access (required for thread context)+ username: The username whose encrypted DB to read. Required —+ without it get_user_db_session would silently fall back to+ the Flask session user (or fail off-request-context, which+ the except below would swallow into a None return), so+ callers must state whose DB they mean.Returns:str: The strategy name or None if not founddiff --git a/tests/web/routes/test_history_routes.py b/tests/web/routes/test_history_routes.pyindex b25c56d401..8f1b6ac12a 100644--- a/tests/web/routes/test_history_routes.py+++ b/tests/web/routes/test_history_routes.py@@ -374,7 +374,10 @@ class TestGetResearchDetails:mock_logs.return_value = []with patch(- "local_deep_research.web.routes.history_routes.get_research_strategy"+ "local_deep_research.web.routes.history_routes.get_research_strategy",+ # autospec so the route's call is validated against the+ # real signature (username is keyword-only and required).+ autospec=True,) as mock_strategy:mock_strategy.return_value = "standard"@@ -392,6 +395,13 @@ class TestGetResearchDetails:assert data["research_id"] == "test-id"assert data["query"] == "Test query"assert data["strategy"] == "standard"+ # The route must scope the strategy lookup to the+ # authenticated user's encrypted DB — never rely on+ # get_user_db_session's implicit Flask-session+ # fallback inside the service function.+ mock_strategy.assert_called_once_with(+ "test-id", username="testuser"+ )class TestGetReport:diff --git a/tests/web/services/test_research_service_coverage.py b/tests/web/services/test_research_service_coverage.pyindex 0c31a7fae2..83f9a269a1 100644--- a/tests/web/services/test_research_service_coverage.py+++ b/tests/web/services/test_research_service_coverage.py@@ -239,7 +239,7 @@ class TestSaveResearchStrategy:save_research_strategy,)- save_research_strategy(1, "x") # should not raise+ save_research_strategy(1, "x", username="u") # should not raiseclass TestGetResearchStrategy:@@ -280,7 +280,7 @@ class TestGetResearchStrategy:get_research_strategy,)- assert get_research_strategy(1) is None+ assert get_research_strategy(1, username="u") is None# ---------------------------------------------------------------------------