Deep Researcher Agent#
The Deep Researcher produces publication-ready research reports through a
multi-phase iterative workflow. It coordinates specialized subagents under
an orchestrator using the deepagents library.
Location: src/aiq_agent/agents/deep_researcher/agent.py
Purpose#
The deep path handles queries that require comprehensive investigation: multi-step research, comparative analyses, and topics that benefit from structured planning and iterative refinement. It produces long-form reports with inline citations and numbered references.
Internal Flow#
with datetime, clarifier_result,
available_documents, tools] B --> C[Initialize middleware stack] C --> D[Orchestrator dispatches
to Planner Subagent] D --> E[Planner: Analyze query] E --> F[Planner: Execute search
queries using tools] F --> G[Planner: Build evidence-grounded
outline with sections] G --> H[Return plan to Orchestrator] H --> I[Begin Research Loop
default: 2 iterations] I --> J[Orchestrator dispatches
to Researcher Subagent] J --> K[Researcher: Execute
search queries] K --> L[Researcher: Synthesize
relevant content] L --> M[Return findings
to Orchestrator] M --> N[Orchestrator: Create/update
draft report sections] N --> O[Orchestrator: Analyze gaps
and identify follow-up queries] O --> P{More iterations?} P -->|yes| J P -->|no| Q[Orchestrator: Catalog
and number citations] Q --> R[Orchestrator: Produce
final polished report] R --> S[Return DeepResearchAgentState
with report in messages] style A fill:#e1f5fe style S fill:#e8f5e9 style D fill:#e8eaf6 style E fill:#fff8e1 style J fill:#fce4ec
Orchestrator-Subagent Interaction#
Subagent Roles#
Subagent |
LLM Role |
Description |
|---|---|---|
Orchestrator |
|
Coordinates subagents, manages research loops, synthesizes drafts, catalogs citations, produces the final report |
|
|
Iteratively builds evidence-grounded outlines through interleaved search and outline optimization; creates 4-6 strategic search queries mapped to report sections |
|
|
Executes search queries using configured tools and synthesizes relevant content from available sources |
All subagents and the orchestrator share a think tool in addition to the
configured research tools. The think tool lets the agent record reasoning,
verify constraints, or plan next steps without taking any external action.
Middleware Stack#
The orchestrator and all subagents share a common middleware stack:
Middleware |
Purpose |
|---|---|
|
Replaces empty |
|
Sanitizes corrupted or hallucinated tool names from LLM responses (custom) |
|
Retries model calls with exponential backoff (max 10 retries) on transient failures |
The agent is constructed with create_deep_agent from the deepagents library (a LangChain library),
which manages subagent coordination internally. Subagents are passed directly
to create_deep_agent rather than being routed through middleware.
State Model#
DeepResearchAgentState#
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
required |
Conversation history with LangGraph message reducer |
|
|
|
User-selected data source IDs for tool filtering |
|
|
|
User information |
|
|
|
Available tools information |
|
|
|
Todo list for research task tracking |
|
|
|
Virtual filesystem for state persistence (uses merge reducer) |
|
|
|
Subagent status tracking |
|
|
|
Clarification log and approved plan context from the Clarifier |
|
|
|
User-uploaded documents with summaries |
The clarifier_result field is injected into the orchestrator prompt when
present, giving the deep researcher access to the approved research plan and
any clarification context.
Configuration#
Configured through DeepResearchAgentConfig (NeMo Agent Toolkit type name: deep_research_agent):
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
required |
LLM for orchestrator and final report generation |
|
|
|
LLM for researcher subagent; falls back to |
|
|
|
LLM for planner subagent; falls back to |
|
|
|
Research tools (web search, paper search, etc.) |
|
|
|
Maximum research iterations |
|
|
|
Enable detailed logging |
Example YAML:
functions:
deep_research_agent:
_type: deep_research_agent
orchestrator_llm: nemotron_llm
researcher_llm: nemotron_llm
planner_llm: nemotron_llm
max_loops: 2
verbose: true
tools:
- web_search_tool
Prompt Templates#
Located in src/aiq_agent/agents/deep_researcher/prompts/:
Template |
Purpose |
Key Variables |
|---|---|---|
|
Main orchestrator instructions for coordinating subagents, synthesizing drafts, and producing the final report |
|
|
Instructions for the planning subagent to build evidence-grounded outlines |
|
|
Instructions for the researcher subagent to execute queries and synthesize content |
|
Workflow Phases#
Phase 1: Research Planning#
The planner subagent analyzes the user query and generates a structured research plan:
Creates 4-6 strategic search queries
Maps queries to report sections
Builds evidence-grounded outlines through interleaved search and outline optimization
Phase 2: Iterative Research#
The workflow executes configurable research loops (default: 2):
Researcher subagent executes search queries using configured tools
Gathers and synthesizes relevant content from available sources
Orchestrator creates or updates draft report sections
Orchestrator analyzes the draft and identifies gaps for follow-up queries
Phase 3: Citation Management#
The orchestrator catalogs all sources:
Numbers citations sequentially
Formats references for the final report
Phase 4: Final Report#
The orchestrator produces the polished report:
Inline citations with numbered references
Structured sections based on the research plan
Publication-ready formatting
Phase 5: Citation Verification (Post-Processing)#
After the orchestrator produces the final report, a deterministic post-processing pipeline verifies all citations against the actual sources retrieved during research. This provides auditability over generated content — every citation in the output is traceable to a source that was actually retrieved, and all verification decisions are logged. This step is always enabled and requires no configuration.
Location: src/aiq_agent/common/citation_verification.py
Source Registry#
During research, a SourceRegistryMiddleware intercepts every tool call and
records the URLs and citation keys returned by search tools (Tavily, Google
Scholar, knowledge layer, etc.) into a per-session SourceRegistry. This
creates a ground-truth record of what sources were actually retrieved.
Citation Verification#
The verify_citations() function validates every citation in the report
against the source registry using a five-level URL matching strategy:
Exact match – raw or normalized URL
Truncation match – report URL is a prefix of exactly one registry URL
Prefix match – normalized report URL is a prefix of a registry URL
Child-path match – report URL path is a subpath of a registry URL (requires 2+ path segments)
Query-subset match – same host and path, report query parameters are a subset of registry parameters
Citations that cannot be matched to any source in the registry are removed.
Each removal is recorded with an audit reason (url_not_in_registry,
citation_key_not_in_registry, or unverifiable).
Knowledge-layer citations (for example, report.pdf, p.15) are matched
against citation keys with lenient page-number comparison.
Report Sanitization#
The sanitize_report() function removes potentially unsafe or unreliable
URLs from the report body:
Shortened URLs (bit.ly, t.co, tinyurl.com, and 13 other shortener domains)
Truncated or garbled URLs (ending in
...or ellipsis characters)IP-address URLs (security concern)
Non-HTTP schemes (
javascript:,data:,vbscript:,file:)
After removals, citations are renumbered to close any gaps in the reference list.
Audit Trail#
The verification result includes:
Field |
Description |
|---|---|
|
Cleaned report text with invalid citations removed |
|
List of removed citations with reasons |
|
List of retained citations with reference numbers |
This provides a complete audit trail of which citations were kept, which were removed, and why – enabling downstream systems or reviewers to inspect verification decisions.
Evaluation#
The Deep Researcher is evaluated using the Deep Research Bench (DRB) which measures research reports using RACE and FACT metrics. Refer to Deep Research Bench for full documentation.