Key-Value Store
Each agent has a private KV store namespace (self.*) and can access shared global keys based on capability grants.
List All Keys
Retrieve all KV pairs for an agent.Agent UUID
Get Key
Retrieve a specific key’s value.Agent UUID
Key name
Key name
Value
Set Key
Create or update a key-value pair.Agent UUID
Key name
Value (any JSON-serializable data)
Delete Key
Remove a key-value pair.Agent UUID
Key name
Session Management
Sessions store conversation history and context window state.List All Sessions
Retrieve all active sessions across agents.Get Session
Retrieve a specific session’s conversation history.Delete Session
Remove a session and its conversation history.Session UUID
Label Session
Assign a human-readable label to a session for easy retrieval.Session UUID
Session label
Find Session by Label
Retrieve a session by its label.Agent UUID
Session label
Session UUID
Total messages
Session label
List Agent Sessions
Get all sessions for a specific agent.Agent UUID
Array of session objects (same schema as List All Sessions)
Create Agent Session
Create a new session for an agent.Agent UUID
Optional session label
Switch Agent Session
Switch an agent to a different session.Agent UUID
Session UUID to switch to
Knowledge Graph
OpenFang stores message embeddings and enables semantic search across conversation history.The knowledge graph API is under active development. Current endpoints are subject to change.
Query Similar Messages
Find messages semantically similar to a query.Query text
Max results to return
Optional: filter to specific agent
Memory Capabilities
Agents must declare memory access in their manifest:agent.toml
["*"]— Full access (read or write all keys)["self.*"]— Own namespace only (agent_id.*)["shared.*"]— Shared global keys["team.alpha.*"]— Team-specific namespace[]— No memory access
- Agents cannot read/write outside their granted capabilities
- Memory operations are logged in the audit trail
- KV keys are isolated by namespace
Memory Backend
OpenFang uses SQLite for memory persistence:- KV store —
~/.openfang/data/memory.dbtablekv_store - Sessions —
~/.openfang/data/memory.dbtablesessions - Embeddings —
~/.openfang/data/memory.dbtableembeddings(future)
Best Practices
Use namespaces for organization
Use namespaces for organization
Prefix keys with namespaces for clarity:
Label important sessions
Label important sessions
Use descriptive labels for sessions you’ll need to reference later:Then retrieve by label:
Compact long sessions regularly
Compact long sessions regularly
Sessions with 100+ messages should be compacted to reduce context window usage:This summarizes old messages while keeping recent ones intact.
Delete unused sessions
Delete unused sessions
Clean up old sessions to reduce storage:Or reset an agent’s session:
Use KV store for structured data
Use KV store for structured data
Store JSON objects for complex state:
Next Steps
Agents API
Manage agent sessions
Workflows API
Store workflow state in KV
Usage Tracking
Monitor memory usage
Security
Memory capability grants
