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
string
Unique memory ID (UUID)
string
Owner agent ID
string
Textual content of the memory
array
Vector embedding (generated automatically)
object
Arbitrary key-value metadata
enum
Memory source type:
conversationdocumentobservationinferenceuser_providedsystem
number
Confidence score (0.0 - 1.0)
string
Memory scope/collection (e.g., “episodic”, “semantic”)
string
ISO 8601 timestamp
string
Last access timestamp
integer
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:string
Filter by agent
enum
Filter by source type
string
Filter by scope/collection
number
Minimum confidence threshold
string
Only memories created after this timestamp
string
Only memories created before this timestamp
object
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:integer
Number of duplicate memories merged
integer
Number of memories whose confidence decayed
integer
Consolidation duration in milliseconds
Export & Import
Export all memory data for backup or migration:integer
Number of entities imported
integer
Number of relations imported
integer
Number of memory fragments imported
array
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