Skip to main content

Overview

OpenFang provides a unified memory substrate with three layers:
  1. Key-Value Store - Structured data storage per agent
  2. Semantic Memory - Vector-based recall with embeddings
  3. 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:
  • conversation
  • document
  • observation
  • inference
  • user_provided
  • system
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 person
  • organization - An organization
  • project - A project
  • concept - A concept or idea
  • event - An event
  • location - A location
  • document - A document
  • tool - A tool
  • custom(string) - Custom type

Relation Types

  • works_at - Entity works at organization
  • knows_about - Entity knows about concept
  • related_to - Entities are related
  • depends_on - Entity depends on another
  • owned_by - Entity is owned by another
  • created_by - Entity was created by another
  • located_in - Entity is located in another
  • part_of - Entity is part of another
  • uses - Entity uses another
  • produces - Entity produces another
  • custom(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:
Import from backup:
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