Design contract
What must the architecture define before storage?
Before choosing storage, define the workload, authenticated identities, source authority, permitted actions, authoritative business state, retention and erasure duties, named consistency guarantee, latency budget, and failure behavior. These contracts determine which records, indexes, queues, and hosts are needed. A database choice cannot repair an undefined authority or retry boundary, and different workloads can justify different layouts.
- Workload: Name the questions, writes, delayed tasks, and proposed side effects.
- Identity: Derive actor, subject, tenant, project, agent, session, and source scope.
- Source authority: Record who supplied each claim and which system can correct it.
- Actions: Separate a model-proposed tool call from host authorization and execution.
- Business state: Declare the system of record for each mutable operational object.
- Retention: Set availability periods for canonical data, derivatives, logs, and backups.
- Erasure: Name covered surfaces, propagation owners, deadlines, and verification checks.
- Consistency: State partition, version, index, session, and stale-read behavior.
- Latency: Allocate time for scope resolution, retrieval, hydration, assembly, and fallback.
- Failure: Define responses for lag, conflict, dependency loss, and ambiguous commit outcomes.
Reference flow
What belongs in an AI agent memory architecture?
The architecture needs an owned path through source admission, identity, formation, canonical records, indexes, retrieval, context, and runtime. Proposed actions need a separate policy and host path. Audit and evaluation cross every stage. This reference decomposition is not a required topology, and business systems remain authoritative for mutable state.
Memory roles affect schemas and retrieval triggers, not store count. Classify them in the memory roles guide.
Vendor-neutral reference architecture
Four paths share stages. Sources and indexes are parallel choices. Audit and evaluation span the flow.
- Sources
- Authenticated scope
- Formation policy
- Canonical records
- Canonical records
- Derived indexes
- Authorized retrieval
- Context assembly
- Context assembly
- Agent runtime
- Proposed tool call
- Policy decision
- Policy decision
- Customer host
- System of record
- Reported receipt
Sequence in reading order
- Sources → authenticated scope → formation policy → canonical records.
- Canonical records → derived indexes → authorized retrieval → context assembly.
- Context assembly → agent runtime → proposed tool call → policy decision.
- Policy decision → customer host → system of record → reported receipt.
- Audit and evaluation span every path. Sources and indexes are parallel choices.
Boundary ownership
- Sources cover conversation, events, tools, documents, and systems.
- Identity resolves actor, subject, tenant, project, agent, session, and source.
- Formation policy owns admission, extraction, normalization, source binding, and writes.
- Canonical storage owns IDs, versions, time, and provenance.
- Index workers maintain structured, temporal, lexical, vector, entity, or graph paths.
- Retrieval services own authorization, fusion, hydration, and context budgets.
- The runtime owns working state, answers, and proposed calls.
- Policy and host code separate decisions, enforcement, live state, and execution.
- Business systems own mutable objects and accepted effects.
- Assurance owners retain audits, traces, evaluations, and erasure evidence.
Scope and host enforcement are trust boundaries covered in the memory security guide. Audit points support tests in the memory evaluation guide. A tool call remains a proposal until the host authenticates, authorizes, checks live state, and applies business rules.
External research
W3C PROV-DM is a W3C Recommendation for lineage relations
A02, not source truth. PAMSPEC
-00 is an individual Internet-Draft and work in progress
illustrating an emerging proposal
A12, not an IETF standard.
External research Living vendor documentation illustrates LangGraph checkpoint and store patterns A13 and one managed AWS AgentCore design A14. Neither defines a neutral requirement.
Records and access paths
How should records and indexes differ?
A canonical memory record governs lifecycle identity, versions, source, time, status, retention, and authority metadata. An index finds candidates through a declared access method, then returns pointers for canonical hydration. Canonical does not mean objectively true or authoritative for business state. Indexes are rebuildable projections by default, though a design may declare a graph canonical.
| Question | Canonical memory record | Memory index |
|---|---|---|
| Primary job | Govern object lifecycle and the current version. | Find object IDs by declared field, keyword, time, vector, entity, or relation. |
| Identity and time | Stable object and version IDs, valid time, record time, and provenance. | Pointers, indexed fields, build version, and scope watermark. |
| Authority | Governs memory-service status under the declared contract. | Scores and edges do not create authority. |
| Update | Compare-and-set, supersession, contest, retention, or deletion changes state. | A worker applies changes and advances its watermark. |
| Read | Hydrates current, historical, or conflicting versions. | Returns bounded candidates under scope filters. |
| Graph boundary | A declared canonical graph preserves source, identity, time, and update semantics. | Otherwise, graph nodes and edges are lagging, rebuildable views. |
Storage patterns follow the contract
A design may pair canonical records with parallel indexes, materialize a canonical view from source events, declare graph relations canonical, or keep source artifacts in object storage. Each pattern still needs version, lineage, lag, and erasure rules.
External research A peer-reviewed article distinguishes valid time from transaction time A03. A published SIGMOD Record industry article describes SQL:2011 application-time and system-versioned features A04. Both motivate explicit time without requiring SQL.
External research Peer-reviewed ACL papers illustrate APEX-MEM's append-only temporal design with entity resolution A10 and MAGMA's semantic, temporal, causal, and entity graph views A11. Neither makes a graph canonical by default.
Read path
How should retrieval become model context?
Retrieval should resolve authenticated scope, apply authorization and lifecycle filters, gather candidates from declared access paths, hydrate canonical records, expose conflicts, and assemble a bounded context pack. Context assembly means selecting, deduplicating, ordering, labeling, and budgeting evidence before a model call. It cannot guarantee a correct answer or turn untrusted memory into instructions.
- Classify the request. Name the subject, task, time basis, required fields, and version floor.
- Resolve scope. Derive actor and tenant authority from authenticated server context.
- Filter before retrieval. Apply authorization before candidate generation where the store permits it.
- Query declared access paths. Structured, temporal, lexical, vector, entity, and graph lookups may run in parallel when their scope semantics match.
- Fuse and hydrate. Deduplicate object IDs, fetch canonical versions, and reject missing references.
- Apply validity rules. Filter superseded, expired, deleted, or out-of-scope items and expose unresolved conflicts.
- Assemble context. Preserve source labels, separate evidence from instructions, order deliberately, and enforce a budget.
- Call the model. Pass the context pack with current task state, not retrieval scores as authority.
External research LongMemEval separates indexing, retrieval, and reading in its evaluation setup A08. Lost in the Middle reports position sensitivity in its published tasks A09. Neither result dictates a production context order for every model or workload.
Write and retry contracts
What consistency and retry contracts are required?
Required contracts name scope and guarantees for reads, writes, indexes, sessions, conflicts, duplicate events, retries, and ambiguous outcomes. Read-your-writes applies within a partition. A version floor sets the oldest acceptable commit, while a watermark states index progress. Idempotency means one logical effect under a key contract, not exactly-once infrastructure.
| Contract | Required rule | Declared failure result |
|---|---|---|
| Read-your-writes | A later partition read sees the acknowledged canonical version. | Wait, route to an eligible store, or return unavailable. |
| Version floor | A read requiring version 42 cannot satisfy the request with version 41. | Canonical lookup satisfies lag only for an identified object with a declared path. It cannot replace semantic candidate generation. Otherwise wait or return unavailable. |
| Index watermark | Each index reports its highest processed scoped commit. | Expose lag rather than treating a stale projection as current. |
| Monotonic reads | A session does not move below an observed version when required. | Return a named stale-session or unavailable response. |
| Compare-and-set | An update supplies the expected version before a successor. | A version mismatch returns conflict without mutation. |
| Duplicate source event | Source plus event ID identifies a replay and binds its payload. | Return the prior outcome, or conflict if the payload differs. |
| Retry key | Define tenant, operation, resource, payload equality, expiry, concurrency, and lookup. | A reused key with a different payload returns conflict. |
| Ambiguous outcome | After response loss, look up the operation before retrying. | Return committed, in progress, failed, or unknown without blind re-execution. |
External research A peer-reviewed PDIS paper supports read-your-writes and monotonic reads A06. CloudEvents 1.0.2 is a stable CNCF specification whose source and event ID support duplicate recognition A07. It does not define memory retry-key behavior.
External research RFC 9110, an IETF Internet Standard, defines method idempotency for repeated identical requests A05. Retry-key and ambiguous-result behavior remain application contracts.
Synthetic correction trace
Cold-chain correction during index lag
Ten-lane correction and read sequence
Ten lanes follow a duplicate sensor event, late correction, lagging index, version-floor read, and host-owned decision.
- Sensor source: sensor-D7-04 emits event E-771 for pallet P-204 at 6.2 C.
- Scope resolver: binds sensor, depot D7, and pallet scope.
- Formation and write policy: marks the duplicate as a replay.
- Canonical store: records version 41, then corrected version 42 at 4.8 C.
- Index worker: temporal and vector watermarks remain at 41.
- Retrieval and context service: receives known pallet P-204, minimum version 42, and a declared canonical path.
- Agent runtime: may propose hold, release, or recheck.
- Customer host: checks identity, policy, live state, and rules.
- Warehouse system: records any accepted operational side effect.
- Audit and evaluation: records the path as the index advances to version 42.
Sequence in reading order
-
Authenticated sensor
sensor-D7-04emits eventE-771for palletP-204at6.2 Cand event time2026-08-28T09:14:22Z. -
The resolver binds the authenticated sensor to depot
D7and palletP-204. Caller text does not set that scope. -
The same source event arrives twice at receipt times
2026-08-28T09:14:29Zand2026-08-28T09:14:34Z. Source plus event ID identifies the replay. -
Canonical version
41records the reading, event and receipt times, source, calibration referenceCAL-D7-118, and unverified status. -
Late event
E-772applies calibration referenceCAL-D7-119. Version42records4.8 Cand supersedes version41as current. -
Temporal and vector index watermarks remain
41after the canonical store commits version42. -
A dispatcher asks whether pallet
P-204may leave depotD7and requires version floor42. The request identifies the object and the design declares its canonical lookup path, so that lookup may satisfy the floor during index lag. It cannot replace semantic candidate generation. Without both conditions, the path waits within its bound or returns unavailable. -
Context assembly excludes version
41as current. It may retain it as historical evidence, then passes the result to the runtime. - The runtime may propose hold, release, or recheck. The customer host authenticates the actor, checks policy, live state, and handling rules, then asks the warehouse system to apply an accepted side effect.
-
The warehouse system remains authoritative for dispatch state.
Memory stores the host-reported result, assurance records the
trace, and the index worker advances to
42.
Bounded product mapping
Current ContextDB mapping
Current ContextDB behavior
Checked against repository snapshot d59c1b9 on August 28, 2026. The pinned Apache SDK is Available, the Cloud gateway is Alpha, and asynchronous Formation is Hosted Alpha.
- Current read boundary
- Factual evolution returns version and primary write-position data. Token-bearing reads are primary-bound by default. Both configured pools point to the primary.
- Current operating boundary
- The hosted gateway and Formation process are single-instance and have no service-level agreement. This snapshot does not establish a deployed read replica, worker fleet, high availability, or the full neutral architecture shown in this guide.
Architecture FAQ
Questions about agent memory architecture
What is the canonical record in an agent memory system?
A canonical record is the memory service's lifecycle record for a stable object. It carries version identity, source, valid time, record time, status, retention, and authority metadata. The service uses it to govern memory state. Canonical does not mean objectively true or authoritative for mutable business state.
How should reads behave while a memory index lags?
Compare the requested version floor with the index watermark. A canonical lookup can satisfy lag only when the request identifies the object and a declared canonical path exists. It cannot replace semantic candidate generation. Without both conditions, wait within the bound or return unavailable. Never present a stale candidate as satisfying the floor.
When should memory formation run asynchronously?
Asynchronous formation fits sources arriving after the response, extraction beyond the request budget, or candidates needing quarantine before commit. It adds queues, retries, ordering, and lag. Keep formation synchronous when the next operation requires committed memory and the system can meet that write contract within the request.
What must an idempotency contract define?
An idempotency contract defines key namespace, operation and resource scope, payload comparison, expiry, concurrency, conflict response, result lookup, and post-commit response loss. Replaying the same logical operation should return its established outcome. Reusing a key with a different payload must return conflict without mutating state.
Where should an agent store delayed intentions?
Delayed intentions belong in durable workflow state with identity, trigger, status, owner, retry policy, cancellation, and completion. A retrieved reminder is not a scheduler. Memory may supply the intention and context, while a workflow engine or host owns wake-up, authorization, execution, and final outcome recording.
How should deletion propagate to derived indexes?
Follow lineage from the canonical record to lexical, vector, temporal, entity, and graph projections. Invalidate scoped caches and summaries. Each worker needs a deletion position or tombstone, retry behavior, and verification scan. Backup and provider deadlines need separate checks, so an index update cannot establish immediate erasure closure.
Source ledger
Primary sources and maturity
Each entry states the source's maturity and the boundary used here. A paper or product document can illustrate one design without establishing a standard architecture or a result for another workload.
- External research CoALA, Sumers et al., 2024. Peer-reviewed TMLR paper. Supports modular memory and action framing, not a required production topology.
- External research W3C PROV-DM. W3C Recommendation. Supports entity, activity, agent, generation, use, attribution, and derivation terms.
- External research Snodgrass and Ahn, 1986. Peer-reviewed IEEE Computer paper. Grounds valid-time and transaction-time distinctions.
- External research Kulkarni and Michels, 2012. Published SIGMOD Record industry article. Describes application-time and system-versioned temporal features in SQL:2011.
- External research HTTP Semantics, RFC 9110 section 9.2.2. IETF Internet Standard. Defines HTTP method idempotency for repeated identical requests, not application retry keys.
- External research Terry et al., 1994. Peer-reviewed PDIS paper. Supports named session guarantees, including read-your-writes and monotonic reads.
- External research CloudEvents 1.0.2. Stable CNCF specification. Supports source and event ID semantics for duplicate recognition, not memory idempotency.
- External research LongMemEval, Wu et al., 2025. Peer-reviewed ICLR paper. Separates indexing, retrieval, and reading in its evaluation setup.
- External research Lost in the Middle, Liu et al., 2024. Peer-reviewed TACL paper. Reports position sensitivity in its published tasks, not a universal context rule.
- External research APEX-MEM, Banerjee et al., 2026. Peer-reviewed ACL paper. Illustrates temporal records with entity resolution and graph views.
- External research MAGMA, Jiang et al., 2026. Peer-reviewed ACL paper. Illustrates semantic, temporal, causal, and entity graph views in the studied system.
- External research PAMSPEC -00. Individual Internet-Draft and work in progress. It is an emerging proposal, not an IETF standard or consensus.
- External research LangGraph persistence. Living vendor documentation. Illustrates current checkpoint and store patterns without defining a field standard.
- External research AWS AgentCore memory. Living vendor documentation. Illustrates one managed design without making its behavior a neutral requirement.