Skip to content

Latest commit

Β 

History

26 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 MyTaskManager

A Stateful AI Task Management Agent with Long-Term Memory

MyTaskManager is an LLM-powered task management agent built with LangGraph that maintains structured user memory across conversations.

Instead of treating every conversation as an isolated interaction, MyTaskManager can remember important information about the user, manage tasks, and retain user-specific instructions. This enables more personalized, context-aware, and stateful interactions.

The project demonstrates how LLMs, LangGraph workflows, structured memory, tool calling, and schema validation can be combined to build a practical memory-enabled AI agent.


πŸš€ Key Features

  • 🧠 Long-Term Memory β€” Maintains useful information across conversations.
  • πŸ’¬ Short-Term Conversational State β€” Preserves context within a conversation thread.
  • πŸ‘€ Profile Memory β€” Stores structured information about the user.
  • βœ… Task Memory β€” Creates and manages structured to-do items.
  • βš™οΈ Instruction Memory β€” Remembers user-specific instructions and preferences for how tasks should be handled.
  • πŸ”€ Conditional Agent Routing β€” Uses LangGraph to dynamically route memory operations.
  • 🧩 Structured Memory Extraction β€” Uses Pydantic schemas for structured information.
  • πŸ”„ Memory Updating β€” Updates existing memories instead of treating every interaction as a new memory.
  • πŸ› οΈ Tool-Based Memory Management β€” Allows the LLM to determine when a memory operation is required.
  • πŸ” Cyclic Agent Workflow β€” Updates memory and returns control to the agent for continued reasoning.

πŸ—οΈ System Architecture

                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                          β”‚      User       β”‚
                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚
                                   β–Ό
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚   MyTaskManager    β”‚
                        β”‚     LangGraph      β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                  β”‚
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚                      β”‚
                       β–Ό                      β–Ό
                Retrieve Memory          User Request
                       β”‚                      β”‚
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”‚
            β”‚          β”‚          β”‚           β”‚
            β–Ό          β–Ό          β–Ό           β”‚
         Profile      ToDo   Instructions     β”‚
            β”‚          β”‚          β”‚           β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β”‚
                       β”‚                      β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                  β–Ό
                           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                           β”‚      LLM      β”‚
                           β”‚    Reasoning  β”‚
                           β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚
                          Memory Update Required?
                                   β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚              β”‚              β”‚
                    β–Ό              β–Ό              β–Ό
                Profile          ToDo       Instructions
                 Update         Update          Update
                    β”‚              β”‚              β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚ Structured Memory  β”‚
                         β”‚     Update         β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚
                                   β–Ό
                           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                           β”‚MyTaskManager β”‚
                           β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                                  β”‚
                                  β–Ό
                            Final Response

🧠 Memory Architecture

A key design principle of MyTaskManager is the separation between short-term conversational state and long-term user memory.

                     MyTaskManager
                           β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚                         β”‚
              β–Ό                         β–Ό
       Short-Term State          Long-Term Memory
              β”‚                         β”‚
              β–Ό                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
       Conversation          Profile   ToDo   Instructions

Short-Term State

Short-term state contains information required to maintain the current conversational flow.

It is associated with the current LangGraph thread/conversation.

Long-Term Memory

Long-term memory contains information that can remain useful beyond the current conversation.

MyTaskManager separates this information into different memory categories:

Profile
ToDo
Instructions

This separation makes memory easier to reason about, update, and retrieve.


πŸ‘€ 1. Profile Memory

Profile memory stores relatively stable information about the user.

Examples include:

Name
Location
Job
Interests
Connections

A structured schema allows the agent to represent this information consistently.

Example:

class Profile(BaseModel):
    name: Optional[str]
    location: Optional[str]
    job: Optional[str]
    connections: list[str]
    interests: list[str]

βœ… 2. To-Do Memory

To-do memory represents actionable tasks and their current state.

A task can contain:

Task
Time to complete
Deadline
Possible solutions
Status

Supported task states include:

not started
in progress
done
archived

Example:

Task:
Complete RAG project

Deadline:
Friday

Status:
in progress

This allows the agent to maintain task context across conversations.


βš™οΈ 3. Instruction Memory

Instruction memory captures how the user wants the agent to behave.

For example:

"When I create a large task, break it into smaller subtasks."

This differs from profile memory.

Profile Memory
    ↓
Facts about the user

To-Do Memory
    ↓
Things the user needs to accomplish

Instruction Memory
    ↓
How the agent should behave

This separation allows MyTaskManager to personalize its behavior over time.


πŸ”„ Agent Workflow

The main agent follows a cyclic workflow.

Step 1 β€” Receive user input

User
 ↓
LangGraph Agent

The agent receives the user's message along with relevant conversational context.

Step 2 β€” Retrieve relevant memory

The agent accesses the user's stored memory categories:

Profile
ToDo
Instructions

The retrieved information becomes additional context for the LLM.

Step 3 β€” LLM reasoning

The LLM determines what should happen next.

Conceptually:

                     User Message
                          β”‚
                          β–Ό
                         LLM
                          β”‚
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚                 β”‚
                 β–Ό                 β–Ό
          No memory update    Memory update
                 β”‚                 β”‚
                 β–Ό                 β–Ό
               Reply          Determine type
                                  β”‚
                           β”Œβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”
                           β–Ό      β–Ό      β–Ό
                        Profile  ToDo  Instructions

Step 4 β€” Conditional routing

LangGraph routes the request to the appropriate memory-update node.

Memory Decision
      β”‚
      β”œβ”€β”€ profile ───────► Profile Update
      β”‚
      β”œβ”€β”€ todo ──────────► ToDo Update
      β”‚
      └── instructions ─► Instruction Update

Step 5 β€” Update structured memory

The selected memory is updated using structured schemas rather than storing arbitrary unstructured text.

Step 6 β€” Return to the agent

After the memory operation completes, the workflow returns to the main agent.

Memory Update
      β”‚
      β–Ό
Main Agent
      β”‚
      β–Ό
Final Response

This cyclic structure allows the agent to incorporate the newly updated memory into its subsequent reasoning.


🧩 Structured Memory with Pydantic

MyTaskManager uses Pydantic models to define the structure of stored information.

This provides:

  • Schema validation
  • Consistent data representation
  • Predictable LLM outputs
  • Easier memory updates
  • Better downstream processing

Instead of relying entirely on free-form text:

"Suman is interested in AI and has a project."

the system can represent information through structured fields.

Profile
β”œβ”€β”€ name
β”œβ”€β”€ location
β”œβ”€β”€ job
β”œβ”€β”€ interests
└── connections

πŸ”€ Why LangGraph?

A simple LLM application follows:

User β†’ LLM β†’ Response

This becomes difficult when an application needs:

  • State
  • Memory
  • Conditional routing
  • Tool calls
  • Multiple processing stages
  • Iterative workflows

LangGraph allows these operations to be represented explicitly as a stateful graph.

             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
             β”‚     Agent    β”‚
             β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚
                    β–Ό
               Decision Node
                    β”‚
             β”Œβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”
             β–Ό      β–Ό      β–Ό
          Profile  ToDo  Instructions
             β”‚      β”‚      β”‚
             β””β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”˜
                    β–Ό
                  Agent

This makes the workflow easier to extend and debug.


πŸ› οΈ Technology Stack

Technology Role
Python Core implementation
LangGraph Stateful agent orchestration
LangChain LLM application framework
OpenAI Large Language Model
Pydantic Structured schemas and validation
Trustcall Structured memory extraction and updates
LangGraph Checkpointing Short-term conversational state
LangGraph Store Long-term memory
Jupyter Notebook Development and experimentation

πŸ“‚ Project Structure

MyTaskManager/
β”‚
β”œβ”€β”€ mytaskmanager.ipynb
β”œβ”€β”€ README.md
└── .gitignore

The primary implementation is currently provided in:

mytaskmanager.ipynb

πŸš€ Getting Started

1. Clone the repository

git clone https://github.com/SKR18156592/MyTaskManager.git
cd MyTaskManager

2. Create a virtual environment

python -m venv .venv

macOS / Linux

source .venv/bin/activate

Windows

.venv\Scripts\activate

3. Install dependencies

pip install langchain langgraph langchain-openai trustcall pydantic

4. Configure the API key

Set your OpenAI API key as an environment variable.

macOS / Linux

export OPENAI_API_KEY="your-api-key"

Windows

setx OPENAI_API_KEY "your-api-key"

Never commit API keys or .env files containing secrets to GitHub.

5. Run the notebook

Open:

mytaskmanager.ipynb

using Jupyter Notebook, JupyterLab, or VS Code.

Run the cells sequentially to initialize the agent and interact with MyTaskManager.


πŸ’¬ Example Interaction

Conversation 1

User:
My name is Suman and I'm preparing for an AI Engineer role.

The agent can identify relevant profile information and store it as structured memory.

Conversation 2

User:
Add "finish my RAG project" to my tasks.

The agent can create a structured to-do item.

Conversation 3

User:
Whenever I have a large task, break it into smaller subtasks.

The agent can store this as an instruction.

Future Conversation

User:
What should I work on today?

The agent can use previously stored task and user context to provide a personalized response.


🎯 What This Project Demonstrates

MyTaskManager demonstrates practical implementation of:

  • Large Language Models
  • AI Agents
  • Stateful AI workflows
  • LangGraph
  • LangChain
  • Long-term memory
  • Short-term conversational state
  • Structured memory
  • Pydantic schemas
  • Tool calling
  • Conditional routing
  • Memory extraction
  • Memory updating
  • Personalized AI assistants
  • Agentic workflow design

πŸ”¬ Design Principles

1. State β‰  Memory

Short-term conversation state and long-term user memory serve different purposes.

Short-Term State
      ↓
Current conversation

Long-Term Memory
      ↓
Information useful across conversations

2. Structured Memory > Raw Conversation History

Rather than repeatedly passing the entire conversation history to the LLM, useful information can be extracted into structured memory.

Conversation
     β”‚
     β–Ό
Information Extraction
     β”‚
     β–Ό
Structured Memory
     β”‚
     β–Ό
Future Retrieval

3. LLM Reasoning + Deterministic Workflow

The LLM handles semantic reasoning while LangGraph controls the execution flow.

LLM
 ↓
Decide
 ↓
LangGraph
 ↓
Route
 ↓
Execute Memory Operation

This separation makes the overall system more controllable.


πŸ“ˆ Future Improvements

The current architecture provides a foundation for a more production-oriented memory system.

Planned improvements include:

πŸ”Ή Persistent Storage

Move beyond an in-memory development store toward persistent storage.

In-Memory Store
      ↓
Production Database

πŸ”Ή Semantic Memory Retrieval

For larger memory collections, introduce embedding-based retrieval.

User Query
    ↓
Embedding
    ↓
Vector Search
    ↓
Relevant Memories
    ↓
LLM

πŸ”Ή Hybrid Retrieval

Combine semantic retrieval with lexical retrieval for better recall.

                 Query
                   β”‚
           β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”
           β–Ό               β–Ό
     Semantic Search   Keyword Search
           β”‚               β”‚
           β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                   β–Ό
                Reranking
                   β”‚
                   β–Ό
             Relevant Memory

πŸ”Ή Memory Deduplication

Detect whether newly extracted information already exists before creating another memory.

πŸ”Ή Conflict Resolution

Handle contradictory information.

Existing:
Location = Delhi

New:
Location = Bengaluru

The memory system should determine whether the new information supersedes the old information.

πŸ”Ή Memory Importance

Classify memories according to their usefulness:

High Importance
Medium Importance
Low Importance
Temporary

This can prevent unnecessary information from accumulating.

πŸ”Ή Memory Expiration

Some memories become stale and should eventually be removed or updated.

Examples:

Temporary deadline
Current project
Short-term preference

πŸ”Ή Evaluation

A production-grade memory system should be evaluated using metrics such as:

Memory Extraction Accuracy
Memory Update Accuracy
Memory Retrieval Precision
Memory Retrieval Recall
Duplicate Memory Rate
Conflict Resolution Accuracy
Latency
Token Usage

🌟 Why MyTaskManager?

Most basic LLM applications follow:

Prompt β†’ LLM β†’ Response

MyTaskManager explores a more capable architecture:

User
 β”‚
 β–Ό
Stateful Agent
 β”‚
 β”œβ”€β”€ Reason
 β”œβ”€β”€ Retrieve Memory
 β”œβ”€β”€ Decide
 β”œβ”€β”€ Update Memory
 └── Respond
 β”‚
 β–Ό
Personalized Interaction

The goal is to move from a stateless chatbot toward a memory-enabled AI agent capable of maintaining useful context over time.


πŸ‘¨β€πŸ’» Author

Suman Kumar Raj

M.Tech β€” IIT Kharagpur

Interested in:

  • Artificial Intelligence
  • Machine Learning
  • Generative AI
  • Large Language Models
  • AI Agents
  • Retrieval-Augmented Generation
  • Agent Memory Systems

⭐ Repository

GitHub: https://github.com/SKR18156592/MyTaskManager

If you find the project useful, consider giving it a ⭐.


πŸ“Œ Project Summary

MyTaskManager is a LangGraph-based stateful AI task-management agent that combines LLM reasoning, structured long-term memory, conditional workflow orchestration, and personalized user context to create more capable conversational task management.

About

A stateful AI task-management agent built with LangGraph, featuring structured long-term memory for user profiles, tasks, and personalized instructions across conversations.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages