ai-setup 5 min read

Memory Grain — Open Standard for AI Agent Memory

OMS defines the .mg container format for immutable, content-addressed AI agent memory. Open standard with SHA-256 hashing, COSE signing, and three specs covering storage, querying, and output.

By
Share: X in
Memory Grain — Open Memory Specification product thumbnail

TL;DR

TL;DR: The Open Memory Specification (OMS) defines .mg — an open, immutable, content-addressed container format for AI agent memory, with配套 query (CAL) and output (SML) languages for a complete memory stack.

Source and Accuracy Notes

⚠️ This section is MANDATORY. All links must be verified from actual source, not guessed.

What Is Memory Grain?

Memory Grain is an open standard for AI agent memory. It solves a fundamental problem: AI agents today have no portable, verifiable way to store and retrieve what they learn across sessions and systems. Each agent frameworkinventates its own memory schema — making memory lock-in to a specific vendor or framework.

OMS (Open Memory Specification) flips this by defining three complementary specs:

  • OMS (.mg) — The container format. Immutable, content-addressed memory grains signed with COSE Sign1 and hashed with SHA-256.
  • CAL (Context Assembly Language) — The query language. Non-destructive, deterministic assembly of context from grain stores.
  • SML (Semantic Markup Language) — The output format. A flat, tag-based markup language optimized for LLM context consumption.

The project describes itself as giving “any AI agent one memory, portable everywhere.”

Three Specs in Detail

OMS — The .mg Container

The core unit is the Memory Grain (.mg file). Each grain is:

  • Immutable — once written, it cannot be modified, only superseded
  • Content-addressed — identified by SHA-256 hash of its content
  • Cryptographically signed — COSE Sign1 signature over the payload
  • Serialized in MessagePack — compact binary format with canonical encoding

OMS defines three implementation levels:

| Level | Description | |---|---| | Level 1 | Read-only grains, SHA-256 + COSE Sign1, type system, canonical MessagePack | | Level 2 | Full serialization, schema validation, multi-modal references, store protocol | | Level 3 | Persistent backend, AES-256-GCM encryption, HKDF key derivation, encrypted search |

CAL — Context Assembly Language

CAL is a declarative query language for assembling context from a grain store without modifying the underlying data. It supports deterministic context assembly — the same query always returns the same context from the same store state.

CAL has six output formats: SML (default), TOON, Markdown, JSON, plain text, and grain dump.

SML — Semantic Markup Language

SML is the output format — a flat, tag-based markup optimized for LLM consumption. Grain type tags serve as epistemic signals, telling an LLM not just what information is, but what kind it is. For example, <observation> tags mark direct sensor inputs while <belief> tags mark agent-derived conclusions.

Setup and Reference Implementation

The reference implementation lives at github.com/openmemoryspec/oms:

git clone https://github.com/openmemoryspec/oms.git
cd oms

The repository includes the full OMS v1.3 specification documents, reference test vectors, and a reference implementation. There is no single install command — OMS is a specification, not a library. Implementations conforming to the spec exist at various levels.

OMS v1.3 is an OWF Final (Open Web Foundation Final) specification — a stable, finalised standard track.

Why It Matters

AI agent memory today is fragmented. Agents built on different frameworks cannot share memory because each defines its own schema. Memory Grain provides a neutral, open standard that any agent can implement regardless of underlying technology.

The design also prioritises correctness over convenience: immutable grains with cryptographic signatures mean agents can audit where information came from. Content-addressing means grains can be deduplicated and distributed across systems without conflict.

Practical Evaluation Checklist

  • [ ] Read the OMS spec — the three specs are all on one page
  • [ ] Understand the three levels — Level 1 is minimal viable implementation, Level 3 adds encryption
  • [ ] Check test vectors in the GitHub repo for spec conformance testing
  • [ ] Review the blog post on SML for output format guidance
  • [ ] Compare with vector databases — OMS is complementary, not competing: vector DBs handle similarity search, OMS handles verifiable memory

Security Notes

OMS at Level 3 adds per-grain AES-256-GCM encryption with per-user HKDF key derivation and blind-index tokens for encrypted search. The specification is designed with GDPR and HIPAA compliance in mind — immutable audit trails with hash chaining.

The cryptographic signing (COSE Sign1) ensures grain authenticity and non-repudiation.

FAQ

Q: Is this a database? A: No. OMS defines a container format and protocol, not a storage backend. Level 3 specifies a store protocol (get/put/delete/list) but leaves the backend implementation to users — filesystem, S3, or a database are all valid.

Q: How does this compare to vector databases? A: They solve different problems. Vector databases excel at similarity search across embeddings. OMS excels at verifiable, auditable, portable memory with epistemic metadata. They are complementary — grains can reference vector embeddings.

Q: What languages have implementations? A: The reference implementation in the oms repo is the canonical implementation. Third-party implementations may exist — check the community implementations list on the Memory Grain website.

Q: Is the spec stable? A: Yes. OMS v1.3 is OWF Final — the highest stability level. The spec documents are on the memorygrain.org/spec/ page.

Conclusion

Memory Grain fills a real gap in the AI agent ecosystem: no open, vendor-neutral standard for agent memory. With OMS, CAL, and SML, it provides a complete stack from storage to query to LLM-optimised output — all under an open standard with cryptographic integrity guarantees.

If you are building AI agents and need portable, auditable memory, OMS is worth evaluating. Read the specs at memorygrain.org and check the test vectors in the GitHub repo.