How It Works
The agent maintains conversation history and uses it to:- Remember previous requests and results
- Resolve ambiguous references (“it”, “that”, “the meeting”)
- Ask follow-up questions
- Provide contextual responses
Conversation State
Fromagent/graph/state.py (AgentState):
Context Window
The agent includes the last 5 messages when processing requests:Multi-turn Patterns
1. Clarifying Questions
When information is missing, the agent asks for details:- Attendee: John
- Date/time: Tomorrow at 2pm
- Duration: 1 hour
2. Reference Resolution
The agent resolves pronouns and references:- “the dentist appointment” → Event from previous response
- “Yes” → Confirmation for pending deletion
3. Iterative Refinement
Users can refine requests across multiple turns:- Remembers last created task ID
- “that” refers to the task
- Incremental updates without re-specifying task
4. Progressive Disclosure
Agent reveals information step-by-step:- First query: Retrieves list
- “the first one” → Email #1 from previous results
- “it” → The email just read
5. Sequential Operations
Chaining multiple operations:- Connects task to calendar event
- Sets appropriate due date (before meeting)
- Maintains focus across related operations
Conversation Flow
Implementation Details
State Management
The agent graph maintains state across nodes:History Format
Conversation history is appended after each interaction:Context in Prompts
Recent history is included in system prompts:Best Practices
For Users
Use Natural References:For Developers
Store Sufficient Context:- Keep last 5-10 messages in history
- Include tool results for reference
- Store entity IDs for easy lookup
Limitations
Common Pitfalls
Lost Context
Problem: Context window too smallAmbiguous References
Problem: Multiple possible referentsConfirmation Interruption
Problem: New request during pending confirmation- Complete confirmation before new requests
- Or cancel pending action explicitly: “No, show me my tasks instead”
Future Enhancements
Planned improvements:
- Persistent history: Save conversations to database
- Entity tracking: Remember all calendar events, tasks, emails discussed
- Semantic search: Find relevant past context
- Session resumption: “What were we talking about yesterday?”
- Proactive suggestions: “You have a meeting in 30 minutes. Want to review the agenda?”
Next Steps
Confirmations
Learn about confirmation flows for destructive operations
Natural Language
Understand how requests are parsed