The Problem: Intent Drift in Real Conversations
Real users don't follow linear conversation paths:
Intent: ANALYZE
User Turn 2: "Focus on Q1"
Intent: ANALYZE (same)
User Turn 3: "Wait, what about 2024 vs 2025?"
Intent: ANALYZE → COMPARE (shift!)
User Turn 4: "Export as CSV"
Intent: ANALYZE → COMPARE → EXPORT (third intent)
User Turn 5: "Never mind, actually can you just summarize the trends?"
Intent: Back to ANALYZE? Or new intent SUMMARIZE?
If your agent doesn't track intent transitions, it gets confused. The user gets frustrated. Bad UX.
What Is Intent (Really)?
Intent is what the user actually wants. Not what they say, but what they need.
- User says: "What's going on with my revenue?"
- Intent: DIAGNOSE (find problems)
- User says: "Can you show me a chart?"
- Intent: VISUALIZE (but also still DIAGNOSE)
- User says: "Export that"
- Intent: EXPORT (but context from DIAGNOSE still matters)
Intent has multiple dimensions:
- Primary intent: What are they doing now? (ANALYZE, COMPARE, EXPORT)
- Secondary intent: What did they do before? (Context)
- Implicit intent: What do they probably want? (Proactive help)
Three Detection Approaches
Approach 1: Classifier-Based (Fast, Limited)
Train a model to classify user messages into predefined intent buckets.
Pros: Fast, reliable for known intents
Cons: Breaks for novel intents, rigid
Good for: Closed-domain systems (e-commerce customer support) Bad for: Open-ended tasks (research, analysis)
Approach 2: LLM-Based Extraction (Flexible, Slower)
Use an LLM to extract intent from context.
User conversation history: [past messages]
Latest user message: "Export as CSV"
Extract: Primary intent, secondary intent, implied needs. Return JSON.
Pros: Handles novel intents, flexible
Cons: Slower, needs LLM call
Approach 3: Hybrid (Best for Production)
Use classifier for known intents (fast). Fall back to LLM for edge cases.
- Classifier predicts intent (50ms)
- If confidence < 70%: LLM extraction (500ms)
- Combine results
Handling Multi-Intent Conversations
Real conversations have multiple intents happening simultaneously:
| Turn | Message | Primary | Secondary |
|---|---|---|---|
| 1 | Analyze sales | ANALYZE | - |
| 2 | Focus on Q1 | FILTER | ANALYZE |
| 3 | Export as CSV | EXPORT | ANALYZE, FILTER |
Your agent needs to track the entire stack, not just the latest intent.
Preventing Intent Drift
Intent drift happens when the agent forgets why the conversation started.
Protection 1: Intent Stack
Maintain a stack of intents:
Latest: EXPORT
When user says "Go back," pop EXPORT from stack → Back to [ANALYZE, FILTER]
Protection 2: Intent Validation
At each turn, re-validate intent:
- Is latest message consistent with current intent?
- If not: Clarify with user
- If yes: Proceed
Protection 3: Context Summarization
Keep a summary of intent chain:
Implementation Pattern
- Extract intent: Classifier or LLM
- Validate intent: Consistent with stack?
- Route to handler: Call appropriate tool/function
- Update stack: Push new intent or pop
- Generate response: Context-aware based on stack
Key Takeaways
✓ Detect primary + secondary intents
✓ Maintain intent stack
✓ Validate at each turn
✓ Use hybrid approach (classifier + LLM)
✓ Prevent drift with context summaries