Memory Backend
The MemoryBackend provides persistent semantic storage for AXON programs, enablingremember and recall operations.
Overview
The memory layer stores semantic values with metadata, enabling:- Cross-execution persistence — Data survives between program runs
- Semantic retrieval — Query by meaning, not just keys
- Scoped storage — Namespace isolation for different memory definitions
- Decay policies — Automatic expiration of stale data
Architecture
Abstract Interface
MemoryEntry
InMemoryBackend (Default)
Overview
The InMemoryBackend is a dict-based implementation for testing and simple use cases. Features:- Fast in-process storage
- Substring-based retrieval (no vector embeddings)
- Tracer integration
- Scoped namespacing
- No persistence across process restarts
- Simple substring matching (not semantic)
- No scalability for large datasets
Implementation
AXON Integration
Memory Declaration
Remember Statement
Recall Statement
Retrieval Scoring
InMemoryBackend Scoring
The default backend uses simple substring matching:| Match Type | Score | Example |
|---|---|---|
| Exact key match | 1.0 | query=“contract_type” → key=“contract_type” |
| Key contains query | 0.7 | query=“contract” → key=“contract_type” |
| Value contains query | 0.4 | query=“NDA” → value=“Non-Disclosure Agreement” |
| No match | 0.0 | Excluded from results |
- Score (descending)
- Timestamp (descending) — newer entries preferred
Example
Scope Filtering
Memory entries can be scoped to namespaces:Storing with Scope
Retrieving with Scope
Clearing by Scope
Trace Integration
All memory operations are traced:Memory Write
Memory Read
Future Backends
Vector DB Backends (Planned)
Phase 4+ expansion will add semantic retrieval via vector databases:Pinecone Backend
Chroma Backend
Usage Example
Setup
Store
Retrieve
Clear
Decay Policies (Planned)
Future memory backends will support automatic decay:Next Steps
Executor
See how memory integrates into execution
Tracer
Understand memory operation tracing
Architecture Overview
Review the complete AXON architecture
