Clarifier Agent#
The Clarifier Agent provides human-in-the-loop (HITL) interaction before deep research begins. It gathers clarifications from the user, generates a structured research plan, and optionally presents the plan for approval.
Location: src/aiq_agent/agents/clarifier/agent.py
Purpose#
Deep research is expensive in both time and compute. The Clarifier reduces wasted effort by:
Asking focused clarification questions to narrow the research scope
Generating a structured research plan with title and sections
Allowing the user to approve, reject, or provide feedback on the plan
The clarifier runs on the deep research path and also when a shallow query
escalates to deep. It can be disabled entirely using enable_clarifier: false
in the orchestrator config.
Internal Flow#
with clarifier_log] M -->|yes| O[Generate research plan
using plan_generation.j2] O --> P[Present plan to user] P --> Q{User decision?} Q -->|approve| R[Return ClarifierResult
plan_approved = true] Q -->|reject| S[Return ClarifierResult
plan_rejected = true] Q -->|feedback| T{iterations < max_plan_iterations?} T -->|yes| U[Regenerate plan
with feedback] U --> P T -->|no| V[Auto-approve plan] V --> R style A fill:#e1f5fe style N fill:#e8f5e9 style R fill:#e8f5e9 style S fill:#ffebee style J fill:#fff3e0 style P fill:#fff3e0
State Model#
ClarifierAgentState#
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
required |
Conversation history with LangGraph message reducer |
|
|
|
Data source IDs for tool filtering |
|
|
|
User-uploaded documents (file name, summary) for context; the user may refer to these |
|
|
|
Maximum clarification Q&A turns |
|
|
|
Accumulated clarification dialog log |
|
|
|
Current clarification turn counter |
|
|
|
Title of the generated research plan |
|
|
|
Section titles for the research plan |
|
|
|
Whether the user approved the plan |
|
|
|
Whether the user rejected the plan |
|
|
|
History of user feedback on plan iterations |
Computed property:
remaining_questions=max_turns - iteration
ClarifierResult#
Returned to the orchestrator after the clarification dialog completes:
Field |
Type |
Description |
|---|---|---|
|
|
Full clarification dialog log |
|
|
Research plan title (if plan approval enabled) |
|
|
Plan section titles |
|
|
Whether the plan was approved |
|
|
Whether the plan was rejected |
The get_approved_plan_context() method formats the approved plan as markdown
for injection into the deep researcher’s orchestrator prompt.
ClarificationResponse#
Structured JSON response parsed from the LLM output during clarification:
Field |
Type |
Description |
|---|---|---|
|
|
Whether more clarification is needed |
|
|
The question to ask the user |
Configuration#
Configured through ClarifierConfig (NeMo Agent Toolkit type name: clarifier_agent):
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
required |
LLM for generating clarification questions |
|
|
|
Separate LLM for plan generation; falls back to |
|
|
|
Tools for context gathering (for example, web search) |
|
|
|
Maximum clarification Q&A turns before auto-completing |
|
|
|
Enable plan preview and approval after clarification |
|
|
|
Maximum plan feedback iterations before auto-approving |
|
|
|
Maximum characters to log from LLM responses |
|
|
|
Enable verbose logging with |
Example YAML:
functions:
clarifier_agent:
_type: clarifier_agent
llm: nemotron_llm
planner_llm: nemotron_llm
tools:
- web_search_tool
max_turns: 3
enable_plan_approval: true
max_plan_iterations: 10
verbose: true
Prompt Templates#
Located in src/aiq_agent/agents/clarifier/prompts/:
Template |
Purpose |
|---|---|
|
Generates clarification questions. Includes conditional sections for uploaded documents context. Instructs the LLM to respond with JSON containing |
|
Generates a structured research plan with title and sections from the clarified query and dialog log. Template variables: |
HITL Interaction Patterns#
The clarifier uses NeMo Agent Toolkit’s user_interaction_manager to prompt the user.
The callback is injected during registration:
Agent: "Could you clarify whether you're interested in renewable energy
adoption in all G7 nations or specific ones?"
User: "Focus on Germany and Japan."
Agent: "Got it. Are you interested in economic impacts from a GDP perspective,
job creation, or both?"
User: "Both GDP impact and job creation."
Agent: [clarification complete, generates plan]
When enable_plan_approval is true:
Agent: "Here is the proposed research plan:
Title: Economic Impacts of Renewable Energy in Germany and Japan
Sections:
- GDP Impact Analysis
- Job Creation Metrics
- Comparative Analysis
Do you approve this plan?"
User: "Add a section on policy frameworks."
Agent: [regenerates plan with feedback]
User: "Approve"
Agent: [returns ClarifierResult with plan_approved=true]
User responses are matched against keyword sets:
Approval: approve, approved, yes, ok, proceed, continue, go ahead, looks good, y, accept
Rejection: reject, rejected, no, cancel, stop, abort, n