Architecture: LangGraph Persistence Backends: Redis, Postgres, MongoDB
Decision​
Deploy a dedicated Redis Stack instance as the primary option, and provide PostgreSQL and MongoDB as additional backend choices for organizations with existing database infrastructure.
| Alternative | Pros | Cons | Decision |
|---|---|---|---|
| Redis Stack + factory (primary) | Correct modules, clean separation, fast | Additional pod | Selected |
| PostgreSQL backend | ACID, relational, existing infra | Heavier, more setup | Selected |
| MongoDB backend | Document-native, flexible, Atlas/DocumentDB | Custom store wrapper | Selected |
| Upgrade rag-redis to Redis Stack | Reuse existing infra | Risk to RAG indexing | Rejected |
| Keep in-memory | Zero infra | State lost on restart | Rejected |
Solution Architecture​
Checkpointer Factory (checkpointer.py)​
# Environment variables:
LANGGRAPH_CHECKPOINT_TYPE=memory # memory (default) | redis | postgres | mongodb
LANGGRAPH_CHECKPOINT_REDIS_URL= # Redis Stack connection string
LANGGRAPH_CHECKPOINT_POSTGRES_DSN= # PostgreSQL DSN
LANGGRAPH_CHECKPOINT_MONGODB_URI= # MongoDB connection URI
LANGGRAPH_CHECKPOINT_TTL_MINUTES=0 # 0 = no expiry
create_checkpointer()returns the appropriate saver based onLANGGRAPH_CHECKPOINT_TYPEget_checkpointer()provides a global singleton- Graceful fallback: if backend is unreachable or package missing, falls back to
InMemorySaver
Store Factory (store.py)​
# Environment variables:
LANGGRAPH_STORE_TYPE=memory # memory (default) | redis | postgres | mongodb
LANGGRAPH_STORE_REDIS_URL= # Redis Stack connection string
LANGGRAPH_STORE_POSTGRES_DSN= # PostgreSQL DSN
LANGGRAPH_STORE_MONGODB_URI= # MongoDB connection URI
| Backend | Implementation | Package |
|---|---|---|
| Redis | _LazyAsyncRedisStore → AsyncRedisStore | langgraph-checkpoint-redis |
| Postgres | _LazyAsyncPostgresStore → AsyncPostgresStore | langgraph-checkpoint-postgres |
| MongoDB | _LazyAsyncMongoDBStore (custom, motor-based) | motor |
Helm Chart (langgraph-redis)​
- New subchart:
charts/ai-platform-engineering/charts/langgraph-redis/ - Image:
redis:8.0-alpine(Redis 8.0+ includes RedisJSON + RediSearch natively) - PVC-backed persistence (2Gi default)
- Controlled via
global.langgraphRedis.enabledcondition - Non-root container with security context hardening
Agent Wiring​
deep_agent.py:InMemorySaver()replaced withcreate_checkpointer()base_langgraph_agent.py: Module-levelMemorySaver()replaced withget_checkpointer()singleton
Components Changed​
Python​
ai_platform_engineering/utils/checkpointer.py(new) — Checkpointer factory (memory/redis/postgres/mongodb)ai_platform_engineering/utils/store.py— Store factory with_LazyAsyncRedisStore,_LazyAsyncPostgresStore,_LazyAsyncMongoDBStoreai_platform_engineering/multi_agents/platform_engineer/deep_agent.py— Usescreate_checkpointer()ai_platform_engineering/utils/a2a_common/base_langgraph_agent.py— Usesget_checkpointer()pyproject.toml— Addedlanggraph-checkpoint-redis>=0.3.5,langgraph-checkpoint-postgres>=2.0.0,langgraph-checkpoint-mongodb>=0.3.0,motor>=3.4.0
Helm​
charts/ai-platform-engineering/charts/langgraph-redis/(new) — Redis Stack subchartcharts/ai-platform-engineering/Chart.yaml— Addedlanggraph-redisdependencycharts/ai-platform-engineering/values.yaml— Addedglobal.langgraphRedis.enabled, postgres/mongodb tocheckpointPersistenceandmemoryPersistencecharts/ai-platform-engineering/charts/supervisor-agent/values.yaml— Added postgres/mongodb tocheckpointPersistence, mongodb tomemoryPersistencecharts/ai-platform-engineering/charts/supervisor-agent/templates/deployment.yaml— Postgres/MongoDB checkpoint and store env varscharts/ai-platform-engineering/charts/agent/values.yaml— Added postgres/mongodb tocheckpointPersistencecharts/ai-platform-engineering/charts/agent/templates/deployment.yaml— Postgres/MongoDB checkpoint env vars
Tests​
tests/test_checkpointer.py— 29 unit tests (config, factory, singleton for all backends)tests/test_redis_store.py— 36 unit tests (Redis, Postgres, MongoDB store wrappers + factory)
Related​
- Spec: spec.md