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(modular_strategy): drop dead constraint-decomposition LLM call (#4217)

LearningCircuitff5f19ce8148
diff --git a/src/local_deep_research/advanced_search_system/strategies/modular_strategy.py b/src/local_deep_research/advanced_search_system/strategies/modular_strategy.py
index bab240d8e0..abc2c84f18 100644
--- a/src/local_deep_research/advanced_search_system/strategies/modular_strategy.py
+++ b/src/local_deep_research/advanced_search_system/strategies/modular_strategy.py
@@ -46,46 +46,8 @@ class LLMConstraintProcessor:
def __init__(self, model):
self.model = model
- async def decompose_constraints_intelligently(self, constraints):
- """Let LLM intelligently break down constraints into searchable elements"""
- constraint_text = "\n".join([f"- {c.description}" for c in constraints])
-
- prompt = f"""
- I have these constraints from a search query:
- {constraint_text}
-
- Please intelligently decompose these constraints into atomic, searchable elements that can be combined in different ways.
-
- For each constraint, provide:
- 1. **Atomic elements** - Break it into smallest meaningful parts
- 2. **Variations** - Different ways to express the same concept
- 3. **Granular specifics** - Specific values, years, numbers, etc.
-
- Example for a time-based constraint:
- - Atomic elements: Break down the main subject into searchable terms
- - Time variations: Different ways to express time periods
- - Granular specifics: Individual years, dates, or specific values mentioned
-
- Return as valid JSON format:
- {{
- "constraint_1": {{
- "atomic_elements": [...],
- "variations": [...],
- "granular_specifics": [...]
- }},
- "constraint_2": {{
- "atomic_elements": [...],
- "variations": [...],
- "granular_specifics": [...]
- }}
- }}
- """
-
- response = await self.model.ainvoke(prompt)
- return self._parse_decomposition(response.content)
-
async def generate_intelligent_combinations(
- self, decomposed_constraints, existing_queries=None, original_query=None
+ self, existing_queries=None, original_query=None
):
"""LLM generates smart combinations of atomic elements"""
@@ -151,18 +113,6 @@ class LLMConstraintProcessor:
response = await self.model.ainvoke(prompt)
return self._parse_combinations(response.content)
- def _parse_decomposition(self, content):
- """Parse LLM decomposition response"""
- result = extract_json(content, expected_type=dict)
- if result is not None:
- return result
-
- # If parsing fails, return empty dict - let the system handle gracefully
- logger.warning(
- "Failed to parse constraint decomposition, returning empty dict"
- )
- return {}
-
def _parse_combinations(self, content):
"""Parse LLM combinations response"""
result = extract_json(content, expected_type=list)
@@ -424,10 +374,6 @@ class ModularStrategy(BaseSearchStrategy):
)
logger.info("🤖 LLM CONSTRAINT PROCESSING ACTIVATED")
- # LLM decomposition and combination
- decomposed = await self.llm_processor.decompose_constraints_intelligently(
- base_constraints
- )
# Pass existing base constraint queries to avoid duplication
existing_queries = [c.description for c in base_constraints]
@@ -437,7 +383,7 @@ class ModularStrategy(BaseSearchStrategy):
intelligent_combinations = (
await self.llm_processor.generate_intelligent_combinations(
- decomposed, existing_queries, query
+ existing_queries, query
)
)
diff --git a/tests/advanced_search_system/strategies/test_modular_strategy.py b/tests/advanced_search_system/strategies/test_modular_strategy.py
index ecdc6d1663..cbceacc531 100644
--- a/tests/advanced_search_system/strategies/test_modular_strategy.py
+++ b/tests/advanced_search_system/strategies/test_modular_strategy.py
@@ -71,35 +71,6 @@ class TestLLMConstraintProcessor:
assert processor.model is mock_model
- def test_parse_decomposition_valid_json(self):
- """Parse decomposition handles valid JSON."""
- from local_deep_research.advanced_search_system.strategies.modular_strategy import (
- LLMConstraintProcessor,
- )
-
- mock_model = Mock()
- processor = LLMConstraintProcessor(mock_model)
-
- content = '{"constraint_1": {"atomic_elements": ["a", "b"]}}'
- result = processor._parse_decomposition(content)
-
- assert isinstance(result, dict)
- assert "constraint_1" in result
-
- def test_parse_decomposition_invalid_json(self):
- """Parse decomposition handles invalid JSON."""
- from local_deep_research.advanced_search_system.strategies.modular_strategy import (
- LLMConstraintProcessor,
- )
-
- mock_model = Mock()
- processor = LLMConstraintProcessor(mock_model)
-
- content = "invalid json content"
- result = processor._parse_decomposition(content)
-
- assert result == {}
-
def test_parse_combinations_valid_json(self):
"""Parse combinations handles valid JSON array."""
from local_deep_research.advanced_search_system.strategies.modular_strategy import (
@@ -338,40 +309,6 @@ class TestExplorerIntegration:
class TestAsyncMethods:
"""Tests for async methods in modular strategy."""
- @pytest.mark.asyncio
- async def test_decompose_constraints_intelligently(self):
- """Test async constraint decomposition."""
- from local_deep_research.advanced_search_system.strategies.modular_strategy import (
- LLMConstraintProcessor,
- )
- from local_deep_research.advanced_search_system.constraints.base_constraint import (
- Constraint,
- ConstraintType,
- )
-
- mock_model = Mock()
- mock_model.ainvoke = AsyncMock(
- return_value=Mock(
- content='{"constraint_1": {"atomic_elements": ["test"]}}'
- )
- )
-
- processor = LLMConstraintProcessor(mock_model)
-
- constraint = Constraint(
- id="1",
- type=ConstraintType.PROPERTY,
- value="test",
- description="Test constraint",
- weight=0.5,
- )
-
- result = await processor.decompose_constraints_intelligently(
- [constraint]
- )
-
- assert isinstance(result, dict)
-
@pytest.mark.asyncio
async def test_generate_intelligent_combinations(self):
"""Test async combination generation."""
@@ -387,7 +324,6 @@ class TestAsyncMethods:
processor = LLMConstraintProcessor(mock_model)
result = await processor.generate_intelligent_combinations(
- {"constraint_1": {"atomic_elements": ["test"]}},
existing_queries=[],
original_query="test query",
)
@@ -424,21 +360,6 @@ class TestAsyncMethods:
class TestErrorHandling:
"""Tests for error handling in modular strategy."""
- def test_parse_decomposition_handles_exception(self):
- """Parse decomposition handles parsing exceptions."""
- from local_deep_research.advanced_search_system.strategies.modular_strategy import (
- LLMConstraintProcessor,
- )
-
- mock_model = Mock()
- processor = LLMConstraintProcessor(mock_model)
-
- # Malformed JSON that would cause exception
- content = '{"incomplete: json'
- result = processor._parse_decomposition(content)
-
- assert result == {}
-
def test_parse_combinations_handles_exception(self):
"""Parse combinations handles parsing exceptions."""
from local_deep_research.advanced_search_system.strategies.modular_strategy import (
diff --git a/tests/advanced_search_system/strategies/test_modular_strategy_high_value.py b/tests/advanced_search_system/strategies/test_modular_strategy_high_value.py
index 2eea5e6d68..fab2e91965 100644
--- a/tests/advanced_search_system/strategies/test_modular_strategy_high_value.py
+++ b/tests/advanced_search_system/strategies/test_modular_strategy_high_value.py
@@ -72,53 +72,6 @@ class TestCandidateConfidence:
# ---------------------------------------------------------------------------
# LLMConstraintProcessor parsing methods
# ---------------------------------------------------------------------------
-class TestLLMConstraintProcessorParseDecomposition:
- """Tests for LLMConstraintProcessor._parse_decomposition()."""
-
- def setup_method(self):
- self.processor = LLMConstraintProcessor(model=MagicMock())
-
- def test_valid_json_dict(self):
- content = json.dumps(
- {
- "constraint_1": {
- "atomic_elements": ["a", "b"],
- "variations": ["v1"],
- "granular_specifics": ["2020"],
- }
- }
- )
- result = self.processor._parse_decomposition(content)
- assert isinstance(result, dict)
- assert "constraint_1" in result
-
- def test_json_embedded_in_text(self):
- content = 'Here is the result:\n```json\n{"key": "value"}\n```\nDone.'
- result = self.processor._parse_decomposition(content)
- assert isinstance(result, dict)
- assert result.get("key") == "value"
-
- def test_invalid_json_returns_empty_dict(self):
- content = "This is not valid JSON at all {{{broken"
- result = self.processor._parse_decomposition(content)
- assert result == {}
-
- def test_empty_string_returns_empty_dict(self):
- result = self.processor._parse_decomposition("")
- assert result == {}
-
- def test_json_list_returns_empty_dict_because_expected_type_is_dict(self):
- content = json.dumps(["a", "b", "c"])
- result = self.processor._parse_decomposition(content)
- # extract_json with expected_type=dict should reject a list -> fallback {}
- assert result == {}
-
- def test_empty_dict_json(self):
- content = json.dumps({})
- result = self.processor._parse_decomposition(content)
- assert result == {}
-
-
class TestLLMConstraintProcessorParseCombinations:
"""Tests for LLMConstraintProcessor._parse_combinations()."""