report_generator: detailed-mode discards initial research synthesis and only passes 1000 chars to outline planner
Author: skbs-engCreated Sep 19, 2026Updated Sep 19, 2026
Describe the bug
In Detailed Report mode (mode == "detailed"), the research workflow first executes initial comprehensive research via system.analyze_topic(query). With autonomous strategies like langgraph-agent, this phase runs up to 50 iterations, fans out parallel subagents ( esearch_subtopic), fetches web pages, and synthesizes a complete, cited report in esults["current_knowledge"].
However, upon handoff to IntegratedReportGenerator.generate_report:
- Truncated Outline Context: In _determine_report_structure (src/local_deep_research/report_generator.py:427), only the first 1,000 characters of indings["current_knowledge"] are extracted (combined_content[:1000]... [truncated]). The remaining synthesized text is ignored when planning the table of contents.
- Initial Synthesis Discarded: In _research_and_generate_sections (src/local_deep_research/report_generator.py:1328), initial_findings is received but only inspected for questions_by_iteration (which is empty {} for agent strategies). The initial synthesized content (current_knowledge) is never injected into subsection prompts, never used as an executive summary or overview, and never included in the final report body. Only the raw links in ll_links_of_system survive into the bibliography.
- Redundant Subsection Research & MIN_ITERATIONS mismatch: IntegratedReportGenerator sets strategy.settings_snapshot["search.iterations"] = 1 and strategy.max_iterations = 1 before researching each subsection. However, LangGraphAgentStrategy.analyze_topic clamps iterations via ffective_max = max(MIN_ITERATIONS, self.max_iterations) where MIN_ITERATIONS = 10. Consequently, each subsection (often 6-12 subsections) runs up to 10 agent reasoning cycles from scratch to research topics the initial agent run already synthesized.
Why this is a problem
- Wasted Compute/Tokens: The extensive initial research phase (potentially tens of LLM calls, tool calls, and subagent runs) is almost entirely thrown away, retaining only the URL list in ll_links_of_system and ~150 words for outline generation.
- Context Loss: Subsections are researched in isolation without access to the rich knowledge already gathered in Phase 1.
- Multiplied Latency: Detailed report generation takes an exorbitant amount of time and token spend re-discovering information that was already present in initial_findings.
Proposed Solutions / Areas for Improvement
- Preserve Initial Findings: Include initial_findings["current_knowledge"] in the final report as an "Executive Summary" or "Overview" section.
- Adaptive / Configurable Outline Context: Allow _determine_report_structure to use a larger or complete context window bounded by settings (e.g. eport.max_context_chars) rather than hardcoded [:1000].
- Inject Phase 1 Knowledge into Subsection Research: Pass relevant segments of initial_findings["current_knowledge"] into subsection_query so subsection researchers build upon prior knowledge rather than researching from a blank slate.
- Agent Strategy Optimization: For autonomous agent strategies (langgraph-agent), consider allowing the agent to generate the structured comprehensive report directly without routing through multi-call subsection regeneration.
Source: LearningCircuit/local-deep-research