Skip to content

~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.

fix: prevent strategy instruction injection when adaptive questions disabled

LearningCircuite1907cb1acf8
diff --git a/src/local_deep_research/advanced_search_system/questions/browsecomp_question.py b/src/local_deep_research/advanced_search_system/questions/browsecomp_question.py
index 09a1b332b2..56165458fb 100644
--- a/src/local_deep_research/advanced_search_system/questions/browsecomp_question.py
+++ b/src/local_deep_research/advanced_search_system/questions/browsecomp_question.py
@@ -225,24 +225,31 @@ DESCRIPTORS: [entity1], [entity2], ...
) -> List[str]:
"""Generate progressively more specific searches based on findings."""
- # Check if recent searches are failing (returning 0 results)
- recent_iterations = [i for i in range(max(1, iteration - 5), iteration)]
- zero_count = sum(
- 1 for i in recent_iterations if results_by_iteration.get(i, 1) == 0
- )
- searches_failing = zero_count >= 3
+ # Only add strategy instructions if we have actual result data (adaptive mode)
+ strategy_instruction = ""
+ if results_by_iteration:
+ # Check if recent searches are failing (returning 0 results)
+ recent_iterations = [
+ i for i in range(max(1, iteration - 5), iteration)
+ ]
+ zero_count = sum(
+ 1
+ for i in recent_iterations
+ if results_by_iteration.get(i, 1) == 0
+ )
+ searches_failing = zero_count >= 3
- # Adjust strategy based on success/failure
- if searches_failing:
- strategy_instruction = """
+ # Adjust strategy based on success/failure
+ if searches_failing:
+ strategy_instruction = """
IMPORTANT: Your recent searches are returning 0 results - they are TOO NARROW!
- Use FEWER constraints (1-2 terms instead of 4-5)
- Try BROADER, more general searches
- Remove overly specific combinations
- Focus on key concepts, not detailed entity combinations
"""
- else:
- strategy_instruction = """
+ else:
+ strategy_instruction = """
Focus on finding the specific answer by combining entities systematically.
"""
diff --git a/src/local_deep_research/defaults/default_settings.json b/src/local_deep_research/defaults/default_settings.json
index 65cd4d4fa7..d6ef4b5a2d 100644
--- a/src/local_deep_research/defaults/default_settings.json
+++ b/src/local_deep_research/defaults/default_settings.json
@@ -742,16 +742,16 @@
},
"focused_iteration.adaptive_questions": {
"category": "focused_iteration",
- "description": "Enables intelligent adaptation of search queries based on previous results. When ON: If 3+ recent searches return 0 results, the LLM is warned that queries are 'too narrow' and instructed to use broader, simpler terms. When OFF: The LLM generates questions without knowing which searches succeeded or failed (stable, main-branch behavior).",
+ "description": "Enables intelligent adaptation of search queries based on previous results. 1=ON: If 3+ recent searches return 0 results, the LLM is warned that queries are 'too narrow'. 0=OFF: Stable main-branch behavior.",
"editable": true,
- "max_value": null,
- "min_value": null,
+ "max_value": 1,
+ "min_value": 0,
"name": "Adaptive Question Generation",
"options": null,
- "step": null,
+ "step": 1,
"type": "SEARCH",
- "ui_element": "checkbox",
- "value": false,
+ "ui_element": "number",
+ "value": 0,
"visible": true
},
"focused_iteration.knowledge_summary_limit": {
diff --git a/src/local_deep_research/search_system_factory.py b/src/local_deep_research/search_system_factory.py
index d69738064b..dde6341fed 100644
--- a/src/local_deep_research/search_system_factory.py
+++ b/src/local_deep_research/search_system_factory.py
@@ -79,11 +79,14 @@ def create_strategy(
)
# Read focused_iteration settings with kwargs override
- enable_adaptive = kwargs.get(
- "enable_adaptive_questions",
- _get_setting(
- settings_snapshot, "focused_iteration.adaptive_questions", False
- ),
+ # adaptive_questions is stored as 0/1 integer, convert to bool
+ enable_adaptive = bool(
+ kwargs.get(
+ "enable_adaptive_questions",
+ _get_setting(
+ settings_snapshot, "focused_iteration.adaptive_questions", 0
+ ),
+ )
)
knowledge_limit = kwargs.get(
"knowledge_summary_limit",
@@ -182,11 +185,14 @@ def create_strategy(
)
# Read focused_iteration settings with kwargs override
- enable_adaptive = kwargs.get(
- "enable_adaptive_questions",
- _get_setting(
- settings_snapshot, "focused_iteration.adaptive_questions", False
- ),
+ # adaptive_questions is stored as 0/1 integer, convert to bool
+ enable_adaptive = bool(
+ kwargs.get(
+ "enable_adaptive_questions",
+ _get_setting(
+ settings_snapshot, "focused_iteration.adaptive_questions", 0
+ ),
+ )
)
knowledge_limit = kwargs.get(
"knowledge_summary_limit",