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.

feat: improve progress milestones and strategy naming

LearningCircuitfcbfc797fde4
diff --git a/.gitleaks.toml b/.gitleaks.toml
index c97aa87d2a..5ca97aa6b8 100644
--- a/.gitleaks.toml
+++ b/.gitleaks.toml
@@ -108,7 +108,9 @@ paths = [
'''src/local_deep_research/web/routes/.*\.py$''',
'''src/local_deep_research/web/services/.*\.py$''',
# JavaScript files use csrfToken variable names (not actual secrets)
- '''src/local_deep_research/web/static/js/.*\.js$'''
+ '''src/local_deep_research/web/static/js/.*\.js$''',
+ # Database session context uses password variable names (not actual secrets)
+ '''src/local_deep_research/database/session_context\.py$'''
]
files = [
"\\.env\\.example$",
@@ -194,7 +196,11 @@ regexes = [
# Allow research_id, user_password in notification flow docs (example code)
'''research_id,\s*user_password''',
# Allow CSRF token patterns in HTML templates
- '''csrf[Tt]oken\s*=\s*document\.querySelector'''
+ '''csrf[Tt]oken\s*=\s*document\.querySelector''',
+ # Thread context password retrieval (session_context.py)
+ '''thread_context\.get\("user_password"\)''',
+ '''thread_context\["user_password"\]''',
+ '''if not password:'''
]
# Target specific files for scanning
diff --git a/src/local_deep_research/advanced_search_system/strategies/base_strategy.py b/src/local_deep_research/advanced_search_system/strategies/base_strategy.py
index b6ac8daa26..a0f5f9b311 100644
--- a/src/local_deep_research/advanced_search_system/strategies/base_strategy.py
+++ b/src/local_deep_research/advanced_search_system/strategies/base_strategy.py
@@ -159,6 +159,7 @@ class BaseSearchStrategy(ABC):
iteration: int,
progress_percent: int,
source_count: int = 0,
+ query: str = "",
) -> None:
"""
Emit progress update for question generation phase.
@@ -167,12 +168,17 @@ class BaseSearchStrategy(ABC):
iteration: Current iteration number
progress_percent: Current progress percentage
source_count: Number of sources found (for iteration > 1)
+ query: The original research query (for iteration 1)
"""
if iteration == 1:
self._update_progress(
- "Generating initial search questions...",
+ f"Generating initial search questions:\n• {query}",
progress_percent,
- {"phase": "question_generation", "iteration": iteration},
+ {
+ "phase": "question_generation",
+ "type": "milestone",
+ "iteration": iteration,
+ },
)
else:
# Show previous questions and source count
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 5060e7be92..b77332aacd 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
@@ -144,12 +144,6 @@ class FocusedIterationStrategy(BaseSearchStrategy):
80 / self.max_iterations
)
- self._update_progress(
- f"Iteration {iteration}/{self.max_iterations}",
- iteration_progress,
- {"phase": f"iteration_{iteration}", "iteration": iteration},
- )
-
# Show context-aware progress message for question generation
self._emit_question_generation_progress(
iteration=iteration,
@@ -157,6 +151,7 @@ class FocusedIterationStrategy(BaseSearchStrategy):
source_count=len(self.all_search_results)
if iteration > 1
else 0,
+ query=query,
)
# Generate questions for this iteration
@@ -242,17 +237,6 @@ class FocusedIterationStrategy(BaseSearchStrategy):
# Track result count for this iteration
self.results_by_iteration[iteration] = len(iteration_results)
- # Update progress
- self._update_progress(
- f"Completed iteration {iteration} - {len(iteration_results)} results",
- iteration_progress + (80 / self.max_iterations / 2),
- {
- "phase": f"iteration_{iteration}_complete",
- "results_count": len(iteration_results),
- "total_results": len(self.all_search_results),
- },
- )
-
# Add iteration finding
finding = {
"phase": f"Iteration {iteration}",
@@ -274,9 +258,9 @@ class FocusedIterationStrategy(BaseSearchStrategy):
# Final synthesis (like source-based - trust the LLM!)
self._update_progress(
- "Generating final synthesis",
+ f"Synthesizing {len(self.all_search_results)} sources from {len(self.questions_by_iteration)} iterations...",
90,
- {"phase": "synthesis"},
+ {"phase": "synthesis", "type": "milestone"},
)
# Use citation handler for final synthesis
@@ -316,11 +300,7 @@ class FocusedIterationStrategy(BaseSearchStrategy):
)
)
- self._update_progress(
- "Search complete",
- 100,
- {"phase": "complete"},
- )
+ # Note: "Search complete" progress is handled by research_service after strategy returns
# Return results
result = {
diff --git a/src/local_deep_research/advanced_search_system/strategies/source_based_strategy.py b/src/local_deep_research/advanced_search_system/strategies/source_based_strategy.py
index 50f65be804..ad62bc9b87 100644
--- a/src/local_deep_research/advanced_search_system/strategies/source_based_strategy.py
+++ b/src/local_deep_research/advanced_search_system/strategies/source_based_strategy.py
@@ -151,20 +151,15 @@ class SourceBasedSearchStrategy(BaseSearchStrategy):
70 / iterations_to_run
)
- self._update_progress(
- f"Starting iteration {iteration}/{iterations_to_run}",
- iteration_progress_base,
- {"phase": f"iteration_{iteration}", "iteration": iteration},
- )
-
# Step 1: Generate or use questions
- # Show context-aware progress message
+ # Show context-aware progress message (includes iteration info)
self._emit_question_generation_progress(
iteration=iteration,
progress_percent=iteration_progress_base + 5,
source_count=len(filtered_search_results)
if iteration > 1
else 0,
+ query=query,
)
# For first iteration, use initial query
@@ -344,21 +339,13 @@ class SourceBasedSearchStrategy(BaseSearchStrategy):
}
findings.append(finding)
- # Mark iteration as complete
- iteration_progress = 5 + iteration * (70 / iterations_to_run)
- self._update_progress(
- f"Completed iteration {iteration}/{iterations_to_run}",
- iteration_progress,
- {"phase": "iteration_complete", "iteration": iteration},
- )
-
# Do we need this filter?
if self.use_cross_engine_filter:
# Final filtering of all accumulated search results
self._update_progress(
- "Performing final filtering of all results",
+ f"Filtering {len(accumulated_search_results_across_all_iterations)} results for relevance...",
80,
- {"phase": "final_filtering"},
+ {"phase": "final_filtering", "type": "milestone"},
)
final_filtered_results = (
self.cross_engine_filter.filter_results(
@@ -388,7 +375,9 @@ class SourceBasedSearchStrategy(BaseSearchStrategy):
# Final synthesis after all iterations
self._update_progress(
- "Generating final synthesis", 90, {"phase": "synthesis"}
+ f"Synthesizing {len(final_filtered_results)} sources from {iterations_to_run} iterations...",
+ 90,
+ {"phase": "synthesis", "type": "milestone"},
)
# Final synthesis
@@ -448,7 +437,7 @@ class SourceBasedSearchStrategy(BaseSearchStrategy):
}
findings.append(finding)
- self._update_progress("Research complete", 100, {"phase": "complete"})
+ # Note: "Research complete" progress is handled by research_service after strategy returns
return {
"findings": findings,
diff --git a/src/local_deep_research/database/session_context.py b/src/local_deep_research/database/session_context.py
index b2e014dc9a..fc02af260c 100644
--- a/src/local_deep_research/database/session_context.py
+++ b/src/local_deep_research/database/session_context.py
@@ -11,6 +11,7 @@ from flask import g, has_app_context, session as flask_session
from loguru import logger
from sqlalchemy.orm import Session
+from ..utilities.thread_context import get_search_context
from .encrypted_db import db_manager
@@ -85,6 +86,15 @@ def get_user_db_session(
f"No password in session store for {username}"
)
+ # Try thread context (for background threads)
+ if not password:
+ thread_context = get_search_context()
+ if thread_context and thread_context.get("user_password"):
+ password = thread_context["user_password"]
+ logger.debug(
+ f"Got password from thread context for {username}"
+ )
+
if not password and db_manager.has_encryption:
raise DatabaseSessionError(
f"Encrypted database for {username} requires password"
diff --git a/src/local_deep_research/web/templates/pages/news-subscription-form.html b/src/local_deep_research/web/templates/pages/news-subscription-form.html
index ea5fbfab06..88fef711ed 100644
--- a/src/local_deep_research/web/templates/pages/news-subscription-form.html
+++ b/src/local_deep_research/web/templates/pages/news-subscription-form.html
@@ -197,8 +197,8 @@
<label for="subscription-strategy" class="ldr-form-label">Search Strategy</label>
<select class="form-select" id="subscription-strategy">
<option value="source-based" {% if (subscription and subscription.search_strategy == 'source-based') or (not subscription and default_settings.search_strategy == 'source-based') %}selected{% endif %}>Source Based (Comprehensive research)</option>
- <option value="focused-iteration" {% if (subscription and subscription.search_strategy == 'focused-iteration') or (not subscription and default_settings.search_strategy == 'focused-iteration') %}selected{% endif %}>Focused Iteration (Fast Q&A)</option>
- <option value="iterative-refinement" {% if (subscription and subscription.search_strategy == 'iterative-refinement') or (not subscription and default_settings.search_strategy == 'iterative-refinement') %}selected{% endif %}>Iterative Refinement (Progressive refinement)</option>
+ <option value="focused-iteration" {% if (subscription and subscription.search_strategy == 'focused-iteration') or (not subscription and default_settings.search_strategy == 'focused-iteration') %}selected{% endif %}>Focused Iteration - Quick (Fast Q&A)</option>
+ <option value="iterative-refinement" {% if (subscription and subscription.search_strategy == 'iterative-refinement') or (not subscription and default_settings.search_strategy == 'iterative-refinement') %}selected{% endif %}>Experimental: Iterative Refinement (Progressive refinement)</option>
</select>
<div class="ldr-form-text">Choose the search strategy that best fits your needs</div>
</div>
diff --git a/src/local_deep_research/web/templates/pages/news.html b/src/local_deep_research/web/templates/pages/news.html
index 45d6e8db6c..a54eb55241 100644
--- a/src/local_deep_research/web/templates/pages/news.html
+++ b/src/local_deep_research/web/templates/pages/news.html
@@ -318,7 +318,7 @@
<select class="form-select" id="news-subscription-strategy">
<option value="news_aggregation">News Aggregation</option>
<option value="source-based">Source Based</option>
- <option value="focused-iteration">Focused Iteration</option>
+ <option value="focused-iteration">Focused Iteration - Quick</option>
<option value="rapid">Rapid Search</option>
</select>
</div>
diff --git a/src/local_deep_research/web/templates/pages/research.html b/src/local_deep_research/web/templates/pages/research.html
index 4775f9e751..4f7d887817 100644
--- a/src/local_deep_research/web/templates/pages/research.html
+++ b/src/local_deep_research/web/templates/pages/research.html
@@ -155,12 +155,12 @@
<label for="strategy">Search Strategy</label>
<select id="strategy" name="strategy" class="ldr-form-control">
<option value="source-based" {% if settings.search_strategy == 'source-based' %}selected{% endif %}>Source-Based (~70% SimpleQA, Comprehensive Research & Text Creation)</option>
- <option value="focused-iteration" {% if settings.search_strategy == 'focused-iteration' %}selected{% endif %}>Focused Iteration (~95% SimpleQA, Fast & Precise Q&A)</option>
- <option value="focused-iteration-standard" {% if settings.search_strategy == 'focused-iteration-standard' %}selected{% endif %}>Focused Iteration - Standard (Standard citation handler, allows "information not found")</option>
- <option value="iterative-refinement" {% if settings.search_strategy == 'iterative-refinement' %}selected{% endif %}>Iterative Refinement (LLM-guided progressive refinement)</option>
- <option value="topic-organization" {% if settings.search_strategy == 'topic-organization' %}selected{% endif %}>Topic Organization (Clusters sources into topics with lead texts)</option>
+ <option value="focused-iteration" {% if settings.search_strategy == 'focused-iteration' %}selected{% endif %}>Focused Iteration - Quick (~95% SimpleQA, Fast & Precise Q&A)</option>
+ <option value="focused-iteration-standard" {% if settings.search_strategy == 'focused-iteration-standard' %}selected{% endif %}>Focused Iteration - Comprehensive (Detailed long-form output with citations)</option>
+ <option value="iterative-refinement" {% if settings.search_strategy == 'iterative-refinement' %}selected{% endif %}>Experimental: Iterative Refinement (LLM-guided progressive refinement)</option>
+ <option value="topic-organization" {% if settings.search_strategy == 'topic-organization' %}selected{% endif %}>Experimental: Topic Organization (Clusters sources into topics with lead texts)</option>
</select>
- <span class="ldr-input-help">Source-Based: Proven strategy for detailed research. Focused Iteration: 2x faster for direct answers. Iterative Refinement: Automatically refines results until comprehensive. Performance varies with LLM and configuration.</span>
+ <span class="ldr-input-help">Source-Based: Proven for detailed research. Focused Iteration Quick: Fast precise Q&A. Focused Iteration Comprehensive: Detailed long-form with citations. Iterative Refinement: LLM-guided progressive refinement.</span>
</div>
</div>