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: Display LLM's reasoning and identified gaps in research results

LearningCircuit1def1be14d1c
diff --git a/src/local_deep_research/advanced_search_system/strategies/iterative_refinement_strategy.py b/src/local_deep_research/advanced_search_system/strategies/iterative_refinement_strategy.py
index e2479fa9dc..0e00f58a65 100644
--- a/src/local_deep_research/advanced_search_system/strategies/iterative_refinement_strategy.py
+++ b/src/local_deep_research/advanced_search_system/strategies/iterative_refinement_strategy.py
@@ -163,12 +163,17 @@ class IterativeRefinementStrategy(BaseSearchStrategy):
f"Confidence: {evaluation.get('confidence', 0):.2f}"
)
- # Record evaluation in history
+ # Record evaluation in history with full details
self.refinement_history.append(
{
"iteration": refinement_count + 1,
"evaluation": evaluation,
"sources_count": len(all_accumulated_sources),
+ "action": evaluation.get("action"),
+ "confidence": evaluation.get("confidence", 0),
+ "gaps": evaluation.get("gaps", []),
+ "reasoning": evaluation.get("reasoning", ""),
+ "query": evaluation.get("refinement_query", ""),
}
)
@@ -283,7 +288,7 @@ class IterativeRefinementStrategy(BaseSearchStrategy):
if "\n" in last_refinement:
_, final_content = last_refinement.split("\n", 1)
- # Build confidence progression
+ # Build confidence progression and evaluation details
confidence_progression = []
for hist in self.refinement_history:
conf = hist["evaluation"].get("confidence", 0)
@@ -295,11 +300,38 @@ class IterativeRefinementStrategy(BaseSearchStrategy):
else "N/A"
)
+ # Build evaluation insights section
+ evaluation_insights = []
+ for i, hist in enumerate(self.refinement_history, 1):
+ gaps = hist.get("gaps", [])
+ reasoning = hist.get("reasoning", "")
+ query = hist.get("query", "")
+ action = hist.get("action", "")
+
+ if gaps or reasoning:
+ evaluation_insights.append(f"""
+**Refinement {i} Analysis:**
+- **Action**: {action}
+- **Gaps Identified**: {", ".join(gaps) if gaps else "None"}
+- **Reasoning**: {reasoning}
+- **Follow-up Query**: {query if query else "N/A"}""")
+
+ insights_section = ""
+ if evaluation_insights:
+ insights_section = f"""
+
+---
+
+## Refinement Analysis
+
+The LLM identified these issues and improvements during the refinement process:
+{"".join(evaluation_insights)}"""
+
# Prepend final answer at top
results["formatted_findings"] = f"""## Final Answer
*After {refinement_count} refinement{"s" if refinement_count != 1 else ""} | Confidence progression: {confidence_str}*
-{final_content}
+{final_content}{insights_section}
---