Intent Agent Architecture
The IntentAgent is a specialized agent that extends the base Agent class with advanced intent mapping and routing capabilities. It analyzes user messages to identify and map them to predefined intents, then routes conversations accordingly using sophisticated filtering and validation mechanisms.
Design Philosophy
The IntentAgent addresses the challenge of routing user messages to appropriate handlers by:
- Intent Recognition: Using vector similarity search to map user messages to predefined intents
- Logical Filtering: Employing LLM-based analysis to filter out logically irrelevant intents
- Entity Validation: Ensuring consistency between entities in user messages and mapped intents
- Smart Routing: Directing conversation flow based on intent types and targets
- Contextual Processing: Injecting intent information into system prompts for context-aware responses
Key Components
IntentState
Extends the base MessagesState to include intent mapping information:
class IntentState(MessagesState):
intent_mapping: dict[str, Any] # Contains mapped intents and metadata
Intent Types
The agent handles different types of intents:
- RAW: Direct text responses returned immediately
- AGENT: Routes to specific sub-agents
- TOOL: Routes to tool execution (implementation varies)
Core Processing Pipeline
The IntentAgent processes conversations through a multi-stage pipeline:
- Intent Mapping: Analyzes user messages using vector similarity search
- Intent Filtering: Uses LLM analysis to remove logically irrelevant matches
- Entity Checking: Validates entity consistency between user input and intents
- Intent Routing: Determines next actions based on mapping results
- Context Injection: Updates system prompts with intent information