AI agent memory and context management
For the complete documentation index see: llms.txt
All documentation pages available in markdown.
This overview page explains how Aerospike Database stores memory and context for AI agents built with LangGraph or Google Agent Development Kit (ADK). It is for developers building stateful agents that must resume after restarts, share sessions across workers, or retain long conversation history.
It applies to Aerospike Database on all supported versions, plus the community packages langgraph-checkpoint-aerospike and adk-aerospike. You need familiarity with Aerospike records, namespaces, and time to live (TTL). After reading, you can choose the right Aerospike-backed memory pattern for LangGraph checkpoints or ADK sessions and follow the linked tutorial for each pattern.
Agent memory and context in Aerospike
Agent memory is the durable state an agent needs to act consistently across turns, restarts, and concurrent workers. It has two common forms:
| Type | What it stores | Example in these tutorials |
|---|---|---|
| Working state | The graph or session snapshot after each step | LangGraph checkpoints, ADK session rows, and events |
| Conversation history | Ordered user and assistant turns | Checkpoint message history and ADK event streams |
Agents rarely send full history to the model on every turn. Frameworks load recent turns for the context window, load full history for audit or export, or rewind to an earlier checkpoint to fork execution. Aerospike-backed integrations support these read patterns through direct key-based reads at the storage layer.
Why Aerospike for agent memory
These tutorials use Aerospike Database for agent memory because its features apply directly to agent lifecycles:
- Automatic session expiry: LangGraph checkpoints stored with
AerospikeSaver(the checkpoint backend from langgraph-checkpoint-aerospike) can carry a per-write TTL. Aerospike removes expired records without a scheduled cleanup job. See the Tutorial: Expiring chat sessions with LangGraph. - TTL extension on read:
Policy.readTouchTtlPercentanddefault-read-touch-ttl-pctcontrol whether reading a record extends its TTL. Set these values to match whether an active session should stay alive when the agent loads its state. - Safe concurrent writes: ADK sessions can receive parallel
append_eventcalls from sub-agents or retried network writes.AerospikeSessionServiceuses atomic, idempotent appends so events and state stay consistent under load. - Unbounded history through sharding: A single Aerospike record has a maximum record size.
AerospikeSessionServicesplits long ADK sessions into segment records and rolls over to a new segment when a page fills, so conversation history can grow without truncation.
Memory patterns
Expiring session checkpoints
LangGraph writes a checkpoint after every graph step. AerospikeSaver stores each checkpoint as an Aerospike record keyed by thread_id and checkpoint_id, and stamps TTL at write time.
Fork and resume from a checkpoint
When an agent path changes after expensive work, restarting wastes API calls and parsing time. LangGraph checkpoints let you list history, load the field values frozen at a past state back into the running graph (also known as rehydrating), and fork to a corrected path while keeping the original checkpoint for reference.
Atomic concurrent session writes
Multi-agent ADK applications can append to the same session from parallel workers. If writes are not atomic or idempotent, retries and concurrent appends can duplicate turns or corrupt session state.
Unbounded history with segment sharding
Long-running ADK conversations can reach thousands of turns. Storing every event in one record eventually hits Aerospike’s per-record size limit. Segment sharding spreads events across numbered segment records while preserving order and supporting partial reads.