Overview
OpenFang provides a unified memory substrate with three layers:- Key-Value Store - Structured data storage per agent
- Semantic Memory - Vector-based recall with embeddings
- Knowledge Graph - Entity-relation graph for structured knowledge
Key-Value Store
Simple key-value storage scoped to individual agents.Get All Keys
GET /api/memory/agents/{id}/kv
Get Value by Key
GET /api/memory/agents/{id}/kv/{key}
Set Value
PUT /api/memory/agents/{id}/kv/{key}
Delete Key
DELETE /api/memory/agents/{id}/kv/{key}
Semantic Memory
Vector-based memory storage with automatic embedding and semantic recall.Memory Fragment Structure
Unique memory ID (UUID)
Owner agent ID
Textual content of the memory
Vector embedding (generated automatically)
Arbitrary key-value metadata
Memory source type:
conversationdocumentobservationinferenceuser_providedsystem
Confidence score (0.0 - 1.0)
Memory scope/collection (e.g., “episodic”, “semantic”)
ISO 8601 timestamp
Last access timestamp
Number of times accessed
Store Memory
Memories are stored via the kernel’s memory trait implementation. To add a memory programmatically:Recall Memories
Perform semantic search over stored memories:Memory Filters
Filter memories by various criteria:Filter by agent
Filter by source type
Filter by scope/collection
Minimum confidence threshold
Only memories created after this timestamp
Only memories created before this timestamp
Metadata key-value filters
Knowledge Graph
Structured entity-relation graph for representing complex knowledge.Entity Types
person- A personorganization- An organizationproject- A projectconcept- A concept or ideaevent- An eventlocation- A locationdocument- A documenttool- A toolcustom(string)- Custom type
Relation Types
works_at- Entity works at organizationknows_about- Entity knows about conceptrelated_to- Entities are relateddepends_on- Entity depends on anotherowned_by- Entity is owned by anothercreated_by- Entity was created by anotherlocated_in- Entity is located in anotherpart_of- Entity is part of anotheruses- Entity uses anotherproduces- Entity produces anothercustom(string)- Custom relation
Add Entity
Add Relation
Query Graph
Memory Consolidation
Optimize and clean up memory storage:Number of duplicate memories merged
Number of memories whose confidence decayed
Consolidation duration in milliseconds
Export & Import
Export all memory data for backup or migration:Number of entities imported
Number of relations imported
Number of memory fragments imported
Import errors encountered
Memory Scopes
Organize memories into scopes for different use cases:- episodic - Conversation-specific memories
- semantic - General knowledge and facts
- procedural - How-to knowledge and procedures
- preferences - User preferences and settings
- observations - Tool outputs and observations
Best Practices
Use Scopes
Organize memories into logical scopes for easier filtering
Set Confidence
Assign confidence scores to help prioritize recall results
Metadata
Enrich memories with metadata for advanced filtering
Consolidate
Periodically consolidate to merge duplicates and decay old memories
Next Steps
Agents API
Learn how agents interact with memory
Workflows API
Use memory in multi-agent workflows