Skip to content

Built an AI-powered multi-agent calendar system using LangGraph, MCP, and Python (FastAPI). Features include intelligent scheduling, rescheduling, and event analysis through orchestrator, scheduler, and analyzer agents with time awareness, conflict resolution, and natural language understanding for seamless automation.

Notifications You must be signed in to change notification settings

Amanastel/langgraph_calendar-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IMPROVED MULTI-AGENT SYSTEM FLOW DOCUMENTATION

This document outlines the enhanced flow for the calendar multi-agent system

📋 ENHANCED MULTI-AGENT FLOW STRUCTURE

🎯 ORCHESTRATOR AGENT (Entry Point)

📥 User Input → 🎯 Orchestrator Agent
    ├── 1. Get Current Time Context
    ├── 2. Classify Intent  
    ├── 3. Route to Specialist Agent
    └── 4. Return Final Result

📅 ENHANCED SCHEDULER AGENT FLOW

User: "Schedule meeting tomorrow at 2 PM"

1. 🕒 GET TIME CONTEXT
   ├── GetCurrentTime() → Current: 2025-07-25 12:45 PM
   └── GetDateRange("tomorrow") → 2025-07-26 00:00 to 23:59

2. 📝 PARSE SCHEDULE REQUEST  
   ├── Extract: title, datetime, duration, priority
   └── Convert "tomorrow 2 PM" → "2025-07-26T14:00:00+05:30"

3. 🔍 CHECK AVAILABILITY
   ├── GetFilteredCalendarEvents(2025-07-26 date range)
   └── Detect conflicts at requested time

4. ⚖️ RESOLVE CONFLICTS (if any)
   ├── High priority: Move existing events
   ├── Low priority: Find alternative slots
   └── No conflicts: Proceed with original time

5. ✅ CREATE EVENT
   ├── CreateCalendarEvent with resolved time
   └── Return success with event details

🔄 ENHANCED RESCHEDULE AGENT FLOW

User: "Move today's 3 PM meeting to tomorrow"

1. 🕒 GET TIME CONTEXT
   ├── GetCurrentTime() → Current: 2025-07-25
   ├── GetDateRange("today") → 2025-07-25 range
   └── GetDateRange("tomorrow") → 2025-07-26 range

2. 🔍 IDENTIFY TARGET EVENT
   ├── GetFilteredCalendarEvents(today's range)
   ├── Find event at 3 PM today
   └── Extract event_id

3. 📅 FIND NEW SLOT
   ├── GetFilteredCalendarEvents(tomorrow's range)
   ├── Find free slots for tomorrow
   └── Select best available time

4. 🔄 RESCHEDULE EVENT
   ├── RescheduleCalendarEvent(event_id, new_time)
   └── Return success confirmation

📊 ENHANCED ANALYZER AGENT FLOW

User: "Show me my events for this week"

1. 🕒 GET TIME CONTEXT
   ├── GetCurrentTime() → Current: 2025-07-25
   └── GetDateRange("this_week") → 2025-07-21 to 2025-07-27

2. 📊 RETRIEVE FILTERED EVENTS
   ├── GetFilteredCalendarEvents(week range)
   └── Filter events by date range

3. 📈 ANALYZE & FORMAT
   ├── Group events by day
   ├── Identify patterns/conflicts
   ├── Calculate free time
   └── Format user-friendly response

4. 📤 RETURN ANALYSIS
   └── Formatted calendar view with insights

🛠️ KEY IMPROVEMENTS NEEDED

1. TIME-AWARE ORCHESTRATOR

def enhanced_orchestrator(state):
    # ALWAYS get time context first
    current_time = get_current_time_tool.func()
    
    # Classify with time awareness
    intent = classify_intent_with_time_context(state.user_input, current_time)
    
    # Route to specialist with time context
    return route_with_time_context(state, intent, current_time)

2. ENHANCED SCHEDULER AGENT

def enhanced_scheduler_flow(state):
    # Step 1: Time Context
    time_context = get_current_time_tool.func()
    
    # Step 2: Parse with time awareness  
    parsed = parse_with_time_context(state.user_input, time_context)
    
    # Step 3: Get relevant events only
    if parsed.get("target_date"):
        events = get_filtered_calendar_events_tool.func({
            "start_date": parsed["target_date"] + "T00:00:00+05:30",
            "end_date": parsed["target_date"] + "T23:59:59+05:30"
        })
    
    # Step 4: Smart conflict resolution
    # Step 5: Create event

3. ENHANCED ANALYZER AGENT

def enhanced_analyzer_flow(state):
    # Step 1: Extract time expression
    time_expr = extract_time_expression(state.user_input)
    
    # Step 2: Get date range
    date_range = get_date_range_tool.func({"time_expression": time_expr})
    
    # Step 3: Get filtered events
    events = get_filtered_calendar_events_tool.func({
        "start_date": date_range["start_date"],
        "end_date": date_range["end_date"]
    })
    
    # Step 4: Analyze and format
    return format_calendar_analysis(events, time_expr)

🎯 IMPLEMENTATION PRIORITY

HIGH PRIORITY:

  1. ✅ Add time tools to multi-agent system (DONE)
  2. 🔧 Update Analyzer Agent to use filtered events
  3. 🔧 Fix Scheduler Agent to use time context
  4. 🔧 Enhance Orchestrator with time awareness

MEDIUM PRIORITY:

  1. 🔧 Improve Reschedule Agent flow
  2. 🔧 Add better conflict resolution
  3. 🔧 Add session persistence

LOW PRIORITY:

  1. 🔧 Add calendar insights/analytics
  2. 🔧 Add natural language improvements
  3. 🔧 Add multi-user support

📝 SAMPLE CONVERSATIONS

Enhanced Flow Example:

User: "What meetings do I have today?"

🎯 Orchestrator:
- GetCurrentTime() → July 25, 2025
- Classify: "analyze" intent
- Route to: Analyzer Agent

📊 Analyzer Agent:
- GetDateRange("today") → 2025-07-25 range
- GetFilteredCalendarEvents(today's range) → 2 events
- Format response: "You have 2 events today..."

✅ Result: Shows only TODAY's events (not old 2024 events)

This enhanced flow ensures:

  • ✅ Proper time awareness
  • ✅ Accurate date filtering
  • ✅ Better user experience
  • ✅ No confusion with old events
  • ✅ Consistent behavior across all agents

About

Built an AI-powered multi-agent calendar system using LangGraph, MCP, and Python (FastAPI). Features include intelligent scheduling, rescheduling, and event analysis through orchestrator, scheduler, and analyzer agents with time awareness, conflict resolution, and natural language understanding for seamless automation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published