ARCHITECTURE · MEMORY · 5 MIN READ

A layered architecture for agent memory

Separate working context, durable state, and long-term recall.

THE SYSTEM BLUEPRINTCOMPONENTS & DATA FLOW
requestprepare turnretrieveload threadcandidate factsapproved writessave stateUser requestAuthenticated scopeAgent loopCurrent task + instructionsContext builderBudget and rank contextWrite policyExtract · verify · expireMemory storesFacts · vectors · graphSession checkpointsResume a specific thread
A conceptual architecture. Each connection represents a responsibility to implement and validate.

The request path

Authenticate the request and establish tenant, user, and thread identifiers. Load the current thread checkpoint. Retrieve a small set of relevant long-term memories. The context builder selects and ranks these inputs within the model’s context budget.

The write path

After the turn, a separate policy identifies candidate facts. Record provenance, subject, timestamps, and expiry. Check for conflicts before replacing older information. Mem0, Letta, Zep, Cognee, or application-owned logic can play different roles in this layer.

Choose a store for each responsibility

  • PostgreSQL: explicit records, ownership, and transactional application state.
  • pgvector or a vector database: semantic retrieval of selected memory records.
  • Redis: time-bounded context and caches, with deliberate persistence settings.
  • A graph store: relationships and time-aware links between entities.

Failure modes to test

Test cross-tenant access, stale preferences, conflicting memories, irrelevant recall, and deletion propagation. A persistent store does not make a remembered statement true. Preserve the evidence behind important facts.

Keep exploring

Add a dedicated memory layer with Mem0Use PostgreSQL and pgvector for agent memoryA context pipeline for a long-running agent