Skip to content

sea-rod/agent_planner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

29 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– Intelligent Schedule Organizer Agent

Python 3.10+ LangGraph License: Apache 2.0

An AI-powered personal productivity planner with semantic memory, built using LangGraph and Groq LLM

This project implements a single-agent agentic AI system that manages your calendar intelligently through natural language interactions. It features semantic memory via Weaviate, Google Calendar integration, and human-in-the-loop decision-making for safe and transparent scheduling.


๐Ÿ“‹ Table of Contents


โœจ Features

๐ŸŽฏ Core Capabilities

  • ๐Ÿ—“๏ธ Multi-Mode Scheduling

    • Planner Mode: Multi-day/week time-blocked schedules (e.g., "Plan my 6-month exam preparation")
    • Reminder Mode: Single-event scheduling (e.g., "Meeting tomorrow at 10 AM")
    • Delete Mode: Smart event removal with confirmation (e.g., "Delete my study sessions")
    • Retrieval Mode: Natural language calendar queries (e.g., "What's on my schedule next month?")
  • ๐Ÿง  Semantic Memory

    • Learns your scheduling preferences over time
    • Retrieves relevant past conversations for context
    • Identifies scheduling patterns and suggests proactive improvements
    • Three Weaviate collections: UserPreference, ConversationMemory, SchedulingPattern
  • โœ‹ Human-in-the-Loop

    • Requires explicit confirmation before calendar modifications
    • Proposes schedules with tradeoff analysis
    • Iterative refinement based on user feedback
    • Transparent reasoning at every step
  • ๐Ÿ”— Google Calendar Integration

    • Real-time calendar synchronization
    • Conflict detection and resolution
    • Event creation, retrieval, and deletion
    • OAuth2 secure authentication
  • ๐Ÿ’ฌ Natural Language Interface

    • Conversational interaction via Gradio web UI
    • Understands vague requests and asks clarifying questions
    • Supports date/time parsing ("next Tuesday", "in 2 weeks")
    • Session persistence across conversations

๐Ÿ—๏ธ Architecture

Single-Agent Design with LangGraph

The system uses LangGraph to implement a state machine with specialized nodes:

Entry Point: retrieve_memory
     |
current_time (inject IST timestamp)
     |
get_event (fetch Google Calendar events)
     |
classify_model (route: planner | reminder | delete | get_event)
     |
+-> scheduler (planner path) -> human_feedback_planner (loop)
+-> model (reminder/get_event path) -> human_feedback_reminder (loop)
+-> model_delete (delete path) -> human_feedback_delete (loop)
     |
tool (execute calendar operations)
     |
refine_model (post-execution feedback)
     |
store_memory (save to Weaviate)
     |
END

Key Architectural Decisions:

  • Single-Agent (Not Multi-Agent): All specialization via prompt engineering, not separate agents
  • Explicit Control Flow: LangGraph's conditional edges enable deterministic routing
  • Interruption Points: interrupt_before nodes pause execution for user approval
  • State Management: Immutable TypedDict state passed between nodes

๐Ÿ› ๏ธ Tech Stack

Component Technology Purpose
Agent Framework LangGraph State machine orchestration, human-in-the-loop
LLM Groq - openai/gpt-oss-20b 20B-parameter open-source model via Groq LPU
Vector Database Weaviate Cloud Semantic memory storage with Cohere embeddings
Embeddings Cohere embed-english-v3.0 Free-tier text vectorization for Weaviate
Calendar API Google Calendar API Event CRUD operations
UI Framework Gradio Web-based chat interface
Authentication OAuth2 (Google) Secure calendar access
Language Python 3.10+ Core implementation

Why These Choices?

  • LangGraph: Best for explicit control flow and human-in-the-loop (vs. CrewAI's autonomy or AutoGen's conversational overhead)
  • Groq gpt-oss-20b: Open-source, cost-effective, sufficient reasoning for scheduling, ultra-low latency
  • Weaviate Cloud: Free managed vector DB with Cohere embeddings, no self-hosting required
  • Gradio: Rapid UI prototyping with minimal frontend code

๐Ÿ“ฆ Prerequisites

  • Python 3.10 or higher
  • Google Cloud Project with Calendar API enabled
  • Weaviate Cloud account (free tier)
  • Cohere API key (free tier for embeddings)
  • Groq API key (for LLM access)

๐Ÿš€ Installation

1. Clone the Repository

git clone https://github.com/yourusername/intelligent-schedule-organizer.git
cd intelligent-schedule-organizer

2. Create Virtual Environment

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

Required packages:

langchain>=0.1.0
langgraph>=0.0.40
langchain-groq>=0.0.1
weaviate-client>=4.0.0
gradio>=4.0.0
google-api-python-client>=2.0.0
google-auth-httplib2>=0.1.0
google-auth-oauthlib>=1.0.0
python-dotenv>=1.0.0
python-dateutil>=2.8.0

โš™๏ธ Configuration

1. Google Calendar API Setup

  1. Go to Google Cloud Console
  2. Create a new project or select an existing one
  3. Enable Google Calendar API
  4. Create OAuth 2.0 credentials (Desktop App)
  5. Download credentials as credentials.json
  6. Place credentials.json in the project root directory

2. Weaviate Cloud Setup

  1. Sign up at Weaviate Cloud
  2. Create a free cluster
  3. Copy your Cluster URL and API Key

3. API Keys Setup

  1. Get Cohere API key from Cohere Dashboard
  2. Get Groq API key from Groq Console

4. Environment Variables

Create a .env file in the project root:

# Weaviate Configuration
WEAVIATE_URL=https://your-cluster-url.weaviate.network
WEAVIATE_API_KEY=your_weaviate_api_key

# Cohere Embeddings (Free Tier)
COHERE_API_KEY=your_cohere_api_key

# Groq LLM
GROQ_API_KEY=your_groq_api_key

Security Note: Never commit .env or credentials.json to version control!


๐ŸŽฎ Usage

Starting the Application

python main.py

The Gradio interface will launch at http://localhost:7860

First Run: Google OAuth Flow

  1. Click the link that appears in your terminal
  2. Sign in with your Google account
  3. Grant calendar access permissions
  4. A token.json file will be created (cached credentials)

Interacting with the Agent

Example Conversations:

1. Schedule a Single Event (Reminder Mode)

You: Schedule a team meeting tomorrow at 10 AM
Agent: I found a free slot on November 8, 2025 at 10:00 AM. Should I create this event?
You: Yes
Agent: โœ… Event created: Team Meeting (Nov 8, 10:00-11:00 AM)

2. Multi-Day Planning (Planner Mode)

You: Create a study schedule for my exams over the next 3 weeks
Agent: To help you plan effectively, I need:
      - Which subjects/topics to cover?
      - How many hours per day can you dedicate?
      - Any fixed commitments I should avoid?
You: Math, Physics, Chemistry. 3 hours per day. I have meetings Wed/Fri afternoons.
Agent: Here's a proposed schedule:
      Week 1: Math (Mon 9-12, Tue 9-12, Thu 9-12)
      Week 2: Physics (Mon 9-12, Tue 9-12, Thu 9-12)
      Week 3: Chemistry (Mon 9-12, Tue 9-12, Thu 9-12)
      Should I add these to your calendar?
You: Go ahead
Agent: โœ… Created 9 study sessions successfully!

3. Calendar Retrieval (Get Event Mode)

You: What events do I have next month?
Agent: You have 12 events scheduled for December 2025:
      - Team Standup (every Mon/Wed/Fri at 9 AM)
      - Project Deadline (Dec 15, 2025)
      - ...

4. Event Deletion (Delete Mode)

You: Delete my study sessions this week
Agent: I found 3 study sessions:
      - Math Study (Nov 8, 9-12 AM)
      - Physics Study (Nov 9, 9-12 AM)
      - Chemistry Study (Nov 10, 9-12 AM)
      Are you sure you want to delete these?
You: Yes, delete them
Agent: โœ… Deleted 3 events successfully.

๐Ÿ“ Project Structure

intelligent-schedule-organizer/
โ”œโ”€โ”€ main.py                      # Gradio UI entry point
โ”œโ”€โ”€ agent.py                     # LangGraph state machine compilation
โ”œโ”€โ”€ utils/
โ”‚   โ”œโ”€โ”€ nodes.py                 # LLM nodes (model, classify, scheduler, etc.)
โ”‚   โ”œโ”€โ”€ state.py                 # AgentState TypedDict definition
โ”‚   โ”œโ”€โ”€ tools.py                 # Tool decorators (@tool for calendar ops)
โ”‚   โ”œโ”€โ”€ google_calendar.py       # Google Calendar API wrapper
โ”‚   โ”œโ”€โ”€ weaviate_memory.py       # Weaviate vector DB wrapper
โ”‚   โ””โ”€โ”€ memory_node.py           # Memory retrieval/storage nodes
โ”œโ”€โ”€ credentials.json             # Google OAuth2 credentials (NOT in repo)
โ”œโ”€โ”€ token.json                   # Cached Google auth token (auto-generated)
โ”œโ”€โ”€ .env                         # Environment variables (NOT in repo)
โ”œโ”€โ”€ requirements.txt             # Python dependencies
โ”œโ”€โ”€ README.md                    # This file
โ””โ”€โ”€ graph.jpg                    # Agent flow diagram

๐Ÿ” How It Works

1. Memory-Augmented Retrieval (RAG Pattern)

Before Processing Each Request:

  1. Semantic Search: Query Weaviate for:

    • Top 3 relevant user preferences (e.g., "User prefers evening workouts")
    • Top 2 similar past conversations
    • Top 3 scheduling patterns (e.g., "User codes Tuesday 9 AM")
  2. Context Injection: Retrieved memories are injected into the system prompt

  3. Personalized Response: The LLM responds with awareness of past patterns without user restatement.

2. Task Classification

The agent uses a dedicated classifier node to route requests with >95% accuracy on diverse inputs.

3. Human-in-the-Loop Workflow

Execution pauses before critical nodes, allowing:

  • User to review proposed schedules
  • Explicit confirmation ("yes", "go ahead")
  • Iterative refinement ("spread over 2 weeks instead")

4. Tool Invocation

When the LLM decides to call a tool, the ToolNode automatically:

  1. Extracts function parameters from LLM output
  2. Invokes the tool
  3. Wraps result in a ToolMessage
  4. Appends to message history

5. Memory Storage

After Successful Interaction, the system stores:

  • Conversation turns (user message + assistant response)
  • Scheduling patterns for future proactive suggestions

๐ŸŽฏ Agent Flow

The agent follows this flow:

  1. Retrieve Memory - Fetch context from Weaviate
  2. Get Current Time - Inject timestamp
  3. Fetch Calendar Events - Get existing schedule
  4. Classify Request - Route to appropriate handler
  5. Process & Propose - Generate schedule/action
  6. Human Feedback - Wait for approval
  7. Execute Tools - Perform calendar operations
  8. Store Memory - Save patterns for future use

๐Ÿ”Œ API Integration

Google Calendar API

Operations Supported:

# Fetch events for a period
events = google_cal.get_events("30d")  # Next 30 days
events = google_cal.get_events("6m")   # Next 6 months
events = google_cal.get_events("2025-12-31")  # Until specific date

# Create event
google_cal.create_event({
    "summary": "Team Meeting",
    "start": {"dateTime": "2025-11-08T10:00:00+05:30"},
    "end": {"dateTime": "2025-11-08T11:00:00+05:30"}
})

# Delete event
google_cal.delete_event(event_id="abc123xyz")

Weaviate Vector Database

Three Collections:

  1. UserPreference - Stores user scheduling preferences
  2. ConversationMemory - Similar past conversations for context
  3. SchedulingPattern - Learned scheduling habits

๐Ÿงช Prompt Engineering

Techniques Used

  1. Token Restriction - Deterministic output
  2. Constraint Enforcement - Prevent premature actions
  3. Schema Specification - Well-formed tool calls
  4. In-Context Examples - Reduce ambiguity
  5. Sentinel Values - State machine triggers

Prompts Overview

Prompt Purpose Effectiveness
MAIN_SYSTEM_PROMPT Core directive High
CLASSIFY_PROMPT Task classification Very High (>95%)
GET_EVENTS_EXTRACTOR_PROMPT Parse time periods High (85%+)
PLANNER_PROMPT Schedule proposal Medium-High (80%)
EVENT_CREATION_PROMPT Generate tool calls High (95%+)
DELETE_PROMPT Confirm deletions High (90%+)

๐Ÿ’ก Examples

Example 1: Context-Aware Scheduling

First Interaction:

You: Schedule a workout
Agent: What time works best for you?
You: 6 PM

Second Interaction (With Memory):

You: Schedule my workout
Agent: I see you usually work out at 6 PM. Should I block tomorrow 6-7 PM?

Example 2: Conflict Resolution

You: Schedule coding session tomorrow 10-12 PM
Agent: โš ๏ธ You have "Team Meeting" at 10-11 AM tomorrow. 
      I can suggest:
      Option A: 12-2 PM (after meeting)
      Option B: 2-4 PM (afternoon slot)
      Which works better?

๐Ÿ› Troubleshooting

Issue: "Failed to connect to Weaviate"

Fix:

  1. Verify credentials in Weaviate Console
  2. Resume cluster if paused (free tier auto-pauses)
  3. Check network connectivity

Issue: "Google Calendar API returned 401"

Fix:

  1. Delete token.json
  2. Re-run python main.py
  3. Complete OAuth flow again

Issue: "Agent keeps asking the same question"

Fix:

  • Use explicit confirmation: "yes", "okay", "go ahead", "confirm"
  • Avoid vague responses

Issue: "Events created with wrong timezone"

Fix:

  • Modify get_current_time() in nodes.py to use your timezone offset

๐Ÿค Contributing

Contributions are welcome!

Contribution Ideas

  • Unit Tests (pytest)
  • Logging system upgrade
  • Timezone configuration
  • Multi-user support
  • Analytics dashboard
  • Recurring events
  • Integration tests

Code Style

  • Follow PEP 8
  • Use type hints
  • Add docstrings
  • Keep prompts in constants

๐Ÿ“„ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.


๐Ÿ™ Acknowledgments

Frameworks & Libraries

  • LangChain & LangGraph - Agent orchestration
  • Groq - LLM inference
  • Weaviate - Vector database
  • Cohere - Embeddings
  • Google - Calendar API
  • Gradio - UI framework

Authors

  • Seamus F. Rodrigues
  • Rohit M Ghosarwadkar

๐Ÿ“Š Project Statistics

  • Lines of Code: ~5,000
  • Nodes: 14
  • Prompts: 6
  • API Integrations: 3
  • Memory Collections: 3
  • Task Types: 4

๐Ÿ”ฎ Future Enhancements

Short-Term

  • Unit tests with pytest
  • Proper logging system
  • Configurable timezone
  • Recurring events

Medium-Term

  • Multi-user authentication
  • Analytics dashboard
  • Email/SMS reminders
  • Conflict visualization

Long-Term

  • Multi-calendar support
  • Voice interface
  • Mobile app
  • Advanced AI planning algorithms

๐Ÿ“ž Support

  • Issues: GitHub Issues
  • Discussions: GitHub Discussions

๐Ÿ“š Resources


Built with โค๏ธ using LangGraph, Groq, and Weaviate

Last Updated: November 7, 2025

About

Intelligent Schedule Organizer Agent

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors