LangGraph is a powerful framework designed to enhance the development of AI-driven applications by providing structured workflows and agent interactions. This seminar focuses on building a ToDo List Agent with memory capabilities using LangGraph. The agent will be able to maintain both short-term context and long-term memory, allowing it to remember user preferences, tasks, and instructions across multiple interactions.
Agents in LangGraph are autonomous entities that can perform tasks, make decisions, and interact with users or other agents. They are designed to handle complex workflows and can be enhanced with memory to maintain context across interactions.
Our agent, task_mAIstro, helps manage a ToDo list and can make decisions to update three types of long-term memory:
- Create or update a user
profilewith general user information - Add or update items in a ToDo list
collection - Update its own
instructionson how to update items to the ToDo list
To implement an agent with memory, we need to:
- Define the Memory Structure: Create schemas to store different types of memories (e.g., user profile, tasks, instructions).
- Integrate Memory into the Agent: Modify the agent to read from and write to memory during interactions.
- Manage Memory Updates: Implement logic to decide when to save or update memories based on the conversation context.
Human input is crucial for enhancing the decision-making process of the agent. By integrating human input, we can:
- Refine Task Details: Allow users to provide additional details or modify tasks.
- Update Preferences: Let users change their preferences or instructions for task management.
- Correct Errors: Enable users to correct any mistakes made by the agent.
Combining human expertise with AI automation ensures that the agent can make more informed decisions. For example, the agent can suggest local businesses for tasks and allow the user to select the most appropriate option.
Our agent, task_mAIstro, utilizes different types of memory:
- Semantic Memory: Stores structured information about user profile and tasks.
- Procedural Memory: Manages user preferences and instructions for creating ToDo items.
- Decision-Making Memory: Decides when to save memories based on conversation context.
Unlike previous chatbots that always reflected on the conversation and saved memories, task_mAIstro will decide when to save memories (items to our ToDo list) and can save to either a user profile or a collection of ToDo items.
State schemas are used to manage the flow of data within the agent. For our ToDo List Agent, we define the following schemas:
- User Profile Schema: Stores personal information about the user (name, location, family members).
- ToDo Collection Schema: Maintains a list of tasks with details like deadlines, estimated time, and specific solutions.
- Instructions Schema: Stores user preferences for how to manage the ToDo list.
LangGraph Studio offers a new way to develop LLM applications by providing a specialized agent IDE that enables visualization, interaction, and debugging of complex agentic applications. It allows you to better understand agent workflows and iterate faster.
- Visual Graphs: See your agent's workflow visually represented
- Interactive Debugging: Step through execution node by node
- State Editing: Modify the state during execution to test different scenarios
- Thread Management: Create and manage multiple threads for testing
- Human-in-the-Loop Testing: Test your agent with human intervention points
To use LangGraph Studio with our ToDo List Agent:
-
Install the LangGraph CLI and start the development server:
pip install --upgrade "langgraph-cli[inmem]" langgraph dev -
Open LangGraph Studio in your browser or use the desktop application.
-
Connect to your project and visualize your agent's workflow.
-
Test your agent with different inputs:
- "My name is Lance. I live in SF with my wife. I have a 1 year old daughter."
- "My wife asked me to book swim lessons for the baby."
- "When creating or updating ToDo items, include specific local businesses / vendors."
-
Add interrupts to walk through the agent execution step by step or interrupt at specific nodes.
-
Edit the state during execution to test different scenarios and fork threads to create alternative graph executions.
LangGraph Studio relies on Docker for containerization, which provides a consistent development environment across different machines. Here's what you need to know about Docker and deployment:
-
Docker Engine: LangGraph Studio requires Docker Engine to be running. Supported runtimes include:
- Docker Desktop
- Orbstack
-
Docker Compose: Version 2.22.0 or higher is required
-
Local Services Access: To access local services like Ollama or Chroma, you'll need to use
host.docker.internalas the hostname instead oflocalhostsince LangGraph Studio runs in its own Docker network.
-
Desktop Application (macOS only):
- Download the latest
.dmgfile from the releases page - Requires Docker Desktop or Orbstack to be running
- Download the latest
-
Web Version (recommended for all platforms):
- Run a local LangGraph server
- Access via web browser
- Works without Docker
- Supports code hot-reloading
- Shorter startup times
LangGraph Studio requires a properly configured langgraph.json file in your project directory. This file specifies:
- Graphs to be loaded
- Environment variables
- Docker configuration
Here's a sample langgraph.json file:
{
"graphs": {
"demo2.task_maistro": {
"demo_data": "demo_inputs.json",
"env_vars": ["GROQ_API_KEY", "MODEL_NAME"]
}
},
"host": "localhost",
"port": 3000,
"dockerfile_lines": [
"RUN apt-get update && apt-get install -y gcc"
]
}Common JSON syntax errors to check:
- Missing commas between properties
- Trailing commas (not allowed in JSON)
- Unquoted property names
- Using single quotes instead of double quotes
To customize your Docker environment, you can add instructions in the dockerfile_lines section:
{
"dockerfile_lines": [
"RUN apt-get update && apt-get install -y gcc"
]
}If you encounter issues with native dependencies during build, you may need to add additional packages to the Docker image through the dockerfile_lines configuration.
To run the demo, follow these steps:
- Navigtate to the
demofolder
cd demo-
Install LangGraph CLI:
pip install --upgrade "langgraph-cli[inmem]" -
Install required dependencies:
pip install -r requirements.txt
-
Set up environment variables in a
.envfile:GROQ_API_KEY=your_groq_api_key MODEL_NAME=your_model_name -
Start LangGraph development server:
langgraph dev
-
Run Docker: Ensure Docker is running before launching LangGraph Studio.
Try the following interactions to test the agent's capabilities:
-
"My name is Lance. I live in SF with my wife. I have a 1 year old daughter."
- The agent will update the user profile with personal information.
-
"My wife asked me to book swim lessons for the baby."
- The agent will add a task to the ToDo list.
-
"When creating or updating ToDo items, include specific local businesses / vendors."
- The agent will update its instructions for creating ToDo items.
-
"I need to fix the jammed electric Yale lock on the door."
- The agent will add another task to the ToDo list.
-
"For the swim lessons, I need to get that done by end of November."
- The agent will update the swim lessons task with a deadline.
-
"I have 30 minutes, what tasks can I get done?"
- The agent will suggest tasks based on time estimates.
-
"Yes, give me some options to call for swim lessons."
- The agent will provide specific solutions for the swim lessons task.
To ensure optimal performance when running in an ASGI web server, the agent code has been updated to use async/await patterns. This prevents blocking calls from degrading performance by:
- Converting node functions to
async def - Using
await asyncio.to_thread()for potentially blocking operations:- Store operations (search, get, put)
- Model inference calls
- Trustcall extractor invocations
The LangGraph framework provides a robust foundation for building AI-driven applications with structured workflows and agent interactions. By implementing a ToDo List Agent with memory, we can create a powerful tool that helps users manage their tasks efficiently while maintaining context across interactions. This seminar has covered the key concepts and steps required to build such an agent, from defining state schemas to integrating human input and managing long-short term memory.
LangGraph Studio enhances the development experience by providing powerful visualization and debugging tools, making it easier to understand and improve our agent's behavior.
- LangGraph Documentation: https://langgraph.ai/docs
- LangGraph GitHub Repository: https://github.com/langgraph/langgraph
- LangGraph CLI Installation Guide: https://langgraph.ai/docs/cli
- LangGraph Studio: https://github.com/langchain-ai/langgraph-studio
