~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(search): fall back to source-based for a non-string delegate strategy (#7562)
Lukas65da19e066ef
diff --git a/changelog.d/7562.bugfix.md b/changelog.d/7562.bugfix.mdnew file mode 100644index 0000000000..0ea8d62a10--- /dev/null+++ b/changelog.d/7562.bugfix.md@@ -0,0 +1 @@+A follow-up research whose saved context holds a non-string `delegate_strategy` (a number, `null` or a list read back from JSON) now falls back to the source-based strategy instead of failing with an `AttributeError`.diff --git a/src/local_deep_research/search_system.py b/src/local_deep_research/search_system.pyindex e53b6856fd..af8b802976 100644--- a/src/local_deep_research/search_system.py+++ b/src/local_deep_research/search_system.py@@ -229,6 +229,14 @@ class AdvancedSearchSystem:if self.research_contextelse "source-based")+ # research_context can be read back from JSON, so the value may+ # be any JSON type; only a name can select a strategy.+ if not isinstance(delegate_strategy_name, str):+ logger.warning(+ f"Ignoring non-string delegate_strategy "+ f"{type(delegate_strategy_name).__name__}; using source-based"+ )+ delegate_strategy_name = "source-based"delegate = create_strategy(strategy_name=delegate_strategy_name,diff --git a/tests/advanced_search_system/test_strategy_contracts.py b/tests/advanced_search_system/test_strategy_contracts.pyindex 14d78330b1..a6485c9030 100644--- a/tests/advanced_search_system/test_strategy_contracts.py+++ b/tests/advanced_search_system/test_strategy_contracts.py@@ -304,20 +304,13 @@ class TestStrategyDispatch:system.strategy.delegate_strategy, SourceBasedSearchStrategy)- @pytest.mark.xfail(- strict=True,- reason=(- "DEFECT: a non-string delegate_strategy (e.g. read back from "- "a JSON research_context) reaches strategy_name.lower() and "- "raises AttributeError instead of degrading to source-based."- ),- )- def test_non_string_delegate_degrades_rather_than_crashing(self):+ @pytest.mark.parametrize("delegate", [123, None, ["focused-iteration"]])+ def test_non_string_delegate_degrades_rather_than_crashing(self, delegate):system = AdvancedSearchSystem(llm=MagicMock(),search=MagicMock(),strategy_name="contextual-followup",- research_context={"delegate_strategy": 123},+ research_context={"delegate_strategy": delegate},)assert isinstance(system.strategy.delegate_strategy, SourceBasedSearchStrategy