Skip to main content
LangChain is a framework for developing applications powered by language models, while LangGraph extends LangChain with graph-based orchestration for complex multi-agent workflows. This guide demonstrates how to use Archil disks to provide persistent memory storage for stateless agents, enabling scalable multi-agent systems with shared state across multiple servers.

Overview

LangGraph enables sophisticated multi-agent architectures where specialized agents (Research, Writer, Reviewer) work together as nodes in a graph. With Archil, you can:
  • Persist agent memory across restarts and deployments
  • Share state between multiple agent instances running on different servers
  • Store checkpoints for complex workflows using LangChain’s checkpointer libraries
  • Scale horizontally while maintaining consistent agent memory

Create an Archil disk

First, follow the Archil Getting Started Guide to create an Archil disk for storing your agent memory and checkpoints.
The --shared flag enables multiple servers to access the same agent memory simultaneously, crucial for distributed multi-agent systems.

Install dependencies

Set up your Python environment with LangChain, LangGraph, and database drivers:

Multi-agent architecture setup

LangGraph uses a “divide-and-conquer” approach where specialized agents handle different aspects of complex tasks. Here’s how to set up a multi-agent system with Research, Writer, and Reviewer agents:

Supervisor pattern implementation

The supervisor pattern coordinates multiple agents and manages the overall workflow. Here’s how to implement it with LangGraph:

Checkpointer integration

LangGraph supports persistent state management through checkpointers. With Archil, you can use simple file-based checkpointing or SQLite for lightweight, persistent storage:

File-based checkpointer

Simple JSON file-based checkpointing for lightweight persistence:

Stateless agent memory persistence

Create a comprehensive memory management system for stateless agents:

Complete multi-agent example

Here’s a complete example that ties everything together:

Advanced features and best practices

Scaling across multiple servers

When running agents across multiple servers, use Archil’s shared disk capabilities:

Monitoring and observability

Track agent performance and system health:

Configuration management

Store configuration in Archil for consistent settings across deployments:

Testing your setup

Validate your LangChain/LangGraph integration with Archil:

Best practices

  1. Memory Management: Regularly clean up old conversation histories and agent memories to prevent storage bloat
  2. Error Handling: Implement robust error handling and recovery mechanisms for distributed agent failures
  3. Security: Store API keys and sensitive configuration in environment variables, not in Archil storage
  4. Performance: Use appropriate checkpointer backends based on your performance requirements (file-based for simplicity, SQLite for structured queries and history)
  5. Monitoring: Implement comprehensive logging and monitoring to track agent performance and system health
  6. Scaling: Use Archil’s shared disk capabilities to enable horizontal scaling of your agent systems
With this setup, you have a robust, scalable multi-agent system that leverages Archil’s persistent storage capabilities to maintain state across deployments and servers, enabling truly stateless agent architectures with persistent memory.