Clarifier Agent#
The Clarifier Agent provides human-in-the-loop (HITL) interaction before deep research begins. It gathers context and, when the request is vague, optionally asks the user to narrow the scope or clarify the type of output requested.
Location: src/aiq_agent/agents/clarifier/agent.py
Purpose#
Deep research is expensive in both time and compute. The Clarifier reduces wasted effort by:
Gathering context (including optional tool calls such as web search) about the request
Asking focused clarification questions only when the request is genuinely ambiguous
Optionally clarifying the type of output the user wants (for example, report, table, comparison, prediction, or brief answer) when that is unclear
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] style A fill:#e1f5fe style N fill:#e8f5e9 style J 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 |
Computed property:
remaining_questions=max_turns - iteration
ClarifierResult#
Returned to the orchestrator after the clarification dialog completes:
Field |
Type |
Description |
|---|---|---|
|
|
Full clarification dialog log |
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 |
|
|
|
Tools for context gathering (for example, web search) |
|
|
|
Maximum clarification Q&A turns before auto-completing |
|
|
|
Maximum characters to log from LLM responses |
|
|
|
Enable verbose logging with |
Example YAML:
functions:
clarifier_agent:
_type: clarifier_agent
llm: nemotron_llm
tools:
- web_search_tool
max_turns: 3
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 |
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, proceeds to deep research]
When the desired output form is unclear, the clarifier may instead ask which type of output you want (for example, a full report, a comparison table, or a brief answer) before research begins.