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: add truncation parameters to BrowseCompQuestionGenerator

LearningCircuit2557bd93750d
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 d4bd30c29d..09a1b332b2 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
@@ -21,10 +21,24 @@ class BrowseCompQuestionGenerator(BaseQuestionGenerator):
4. Focus on verifiable facts
"""
- def __init__(self, model):
+ def __init__(
+ self,
+ model,
+ knowledge_truncate_length: int = 1500,
+ previous_searches_limit: int = 10,
+ ):
+ """Initialize the question generator.
+
+ Args:
+ model: The LLM model to use for generation
+ knowledge_truncate_length: Max chars for knowledge in prompts (None=unlimited)
+ previous_searches_limit: Max previous searches to show (None=unlimited)
+ """
super().__init__(model)
self.extracted_entities = {}
self.search_progression = []
+ self.knowledge_truncate_length = knowledge_truncate_length
+ self.previous_searches_limit = previous_searches_limit
def generate_questions(
self,
@@ -245,7 +259,7 @@ Entities Found:
- Key Features: {", ".join(entities["descriptors"][:3])}
Current Knowledge Summary:
-{current_knowledge}
+{current_knowledge[: self.knowledge_truncate_length] if self.knowledge_truncate_length else current_knowledge}
Previous Searches:
{self._format_previous_searches(questions_by_iteration, results_by_iteration)}
@@ -324,13 +338,22 @@ Format: One search per line
for iteration, questions in questions_by_iteration.items():
if isinstance(questions, list):
result_count = results_by_iteration.get(iteration, "?")
- for q in questions:
- formatted.append(
- f"Iteration {iteration}: {q} ({result_count} results)"
- )
- return "\n".join(
- formatted
- ) # Show all previous searches to avoid duplicates
+ # Limit questions per iteration (main uses 3)
+ questions_to_show = (
+ questions[:3] if self.previous_searches_limit else questions
+ )
+ for q in questions_to_show:
+ # Only show result counts if we have actual data (not "?")
+ if result_count != "?":
+ formatted.append(
+ f"Iteration {iteration}: {q} ({result_count} results)"
+ )
+ else:
+ formatted.append(f"Iteration {iteration}: {q}")
+ # Apply limit if configured (main uses last 10)
+ if self.previous_searches_limit:
+ return "\n".join(formatted[-self.previous_searches_limit :])
+ return "\n".join(formatted)
def _was_searched(self, term: str, questions_by_iteration: dict) -> bool:
"""Check if a term was already searched."""
diff --git a/src/local_deep_research/advanced_search_system/questions/flexible_browsecomp_question.py b/src/local_deep_research/advanced_search_system/questions/flexible_browsecomp_question.py
index 58a964c9d2..120a1151d9 100644
--- a/src/local_deep_research/advanced_search_system/questions/flexible_browsecomp_question.py
+++ b/src/local_deep_research/advanced_search_system/questions/flexible_browsecomp_question.py
@@ -53,7 +53,7 @@ Previous searches with results:
{self._format_previous_searches(questions_by_iteration, results_by_iteration)}
Current findings:
-{current_knowledge}
+{current_knowledge[: self.knowledge_truncate_length] if self.knowledge_truncate_length else current_knowledge}
Create {num_questions} diverse search queries. Avoid exact duplicates. One per line.
"""
diff --git a/src/local_deep_research/advanced_search_system/strategies/focused_iteration_strategy.py b/src/local_deep_research/advanced_search_system/strategies/focused_iteration_strategy.py
index 0f6cc45c96..bd36c88d25 100644
--- a/src/local_deep_research/advanced_search_system/strategies/focused_iteration_strategy.py
+++ b/src/local_deep_research/advanced_search_system/strategies/focused_iteration_strategy.py
@@ -98,7 +98,15 @@ class FocusedIterationStrategy(BaseSearchStrategy):
# Initialize specialized components
if use_browsecomp_optimization:
- self.question_generator = BrowseCompQuestionGenerator(self.model)
+ # Main branch uses 1500 char truncation and 10 previous searches limit
+ # When matching main behavior, use these limits
+ self.question_generator = BrowseCompQuestionGenerator(
+ self.model,
+ knowledge_truncate_length=1500
+ if knowledge_summary_limit
+ else None,
+ previous_searches_limit=10 if knowledge_summary_limit else None,
+ )
self.explorer = ProgressiveExplorer(self.search, self.model)
else:
# Fall back to standard components
diff --git a/src/local_deep_research/search_system_factory.py b/src/local_deep_research/search_system_factory.py
index ebd48a17c3..2df525c7d5 100644
--- a/src/local_deep_research/search_system_factory.py
+++ b/src/local_deep_research/search_system_factory.py
@@ -131,8 +131,11 @@ def create_strategy(
FlexibleBrowseCompQuestionGenerator,
)
+ # Pass same truncation settings to flexible generator
strategy.question_generator = FlexibleBrowseCompQuestionGenerator(
- model
+ model,
+ knowledge_truncate_length=1500 if knowledge_limit else None,
+ previous_searches_limit=10 if knowledge_limit else None,
)
return strategy
@@ -207,8 +210,11 @@ def create_strategy(
FlexibleBrowseCompQuestionGenerator,
)
+ # Pass same truncation settings to flexible generator
strategy.question_generator = FlexibleBrowseCompQuestionGenerator(
- model
+ model,
+ knowledge_truncate_length=1500 if knowledge_limit else None,
+ previous_searches_limit=10 if knowledge_limit else None,
)
return strategy