Principle:Langchain ai Langgraph Async Store Operations
| Knowledge Sources | |
|---|---|
| Domains | Store, Async, Persistence |
| Last Updated | 2026-02-11 15:00 GMT |
Overview
Async Store Operations is the principle of providing non-blocking, asynchronous key-value storage with optional vector search and TTL-based expiration for LangGraph agents.
Description
LangGraph agents frequently need persistent storage beyond checkpoint state -- for example, user preferences, conversation memories, or document embeddings that span across threads and sessions. Async Store Operations addresses this need through asynchronous store implementations that provide a namespaced key-value interface backed by durable databases.
Each async store organizes items by namespace tuples (e.g., `("users", "123")`) and string keys, forming a hierarchical storage structure. The core operations include `aput()` for storing items, `aget()` for retrieval, `adelete()` for removal, `asearch()` for querying with optional filters, and `alist_namespaces()` for namespace discovery. All operations are fully asynchronous and protected by `asyncio.Lock` for thread safety.
Two advanced capabilities extend the basic key-value model. Vector search integrates embedding models (via pgvector for Postgres or sqlite-vec for SQLite) to enable semantic similarity queries over stored items. TTL (time-to-live) provides automatic item expiration through configurable lifetimes and a background sweeper task, with optional refresh-on-read behavior that extends item lifetime when accessed.
Usage
Use async store operations when LangGraph agents need persistent, cross-session storage in async applications:
- User preferences and profiles that persist across conversations.
- Long-term memory for agents that accumulate knowledge over time.
- Semantic retrieval of stored documents or memories via vector search.
- Ephemeral data that should auto-expire using TTL configuration.
Choose `AsyncPostgresStore` for production workloads with connection pooling and pgvector. Choose `AsyncSqliteStore` for development, testing, and lightweight deployments.
Theoretical Basis
Async Store Operations is grounded in several design principles:
1. Namespace-based organization: The tuple-based namespace model provides a natural hierarchy for multi-tenant and multi-user data. Agents can scope their reads and writes to specific namespace prefixes, ensuring data isolation without separate database schemas.
2. Embedding-augmented retrieval: By integrating vector embeddings directly into the store layer, agents gain semantic search capabilities without requiring a separate vector database. The store automatically generates embeddings for specified document fields during writes and uses vector similarity during search, abstracting the complexity of embedding pipelines.
3. TTL-based lifecycle management: Time-to-live support enables the store to self-manage data freshness. The background sweeper pattern -- a long-running async task that periodically removes expired items -- ensures that stale data is cleaned up without requiring explicit garbage collection by application code. The refresh-on-read option implements a least-recently-used eviction strategy where frequently accessed items are preserved.