Memory and State
Learn how OrionOS agents store and recall information across conversations.
Overview
OrionOS agents maintain memory and state to provide context-aware, personalized interactions. The memory system enables agents to remember past conversations, user preferences, and learned information.
Memory Types
Short-Term Memory
Conversation context within a single session:
{
"memory": {
"shortTermContext": 10,
"contextWindow": "last_10_messages"
}
}Long-Term Memory
Persistent storage across sessions:
{
"memory": {
"enabled": true,
"longTermEnabled": true,
"rememberUsers": true,
"rememberConversations": true,
"retentionDays": 90
}
}Knowledge Base
Static information the agent knows:
{
"knowledge": [
"Expert in DeFi protocols",
"Understanding of yield farming",
"Knowledge of liquidity pools"
]
}State Management
User State
// Store user preferences
await agent.state.setUserData(userId, {
preferences: { language: 'en', theme: 'dark' },
history: []
});
// Retrieve user state
const userData = await agent.state.getUserData(userId);Conversation State
// Track conversation context
await agent.state.setContext(conversationId, {
topic: 'DeFi',
lastMessage: 'What is yield farming?',
entities: ['DeFi', 'yield farming']
});Memory Configuration
{
"memory": {
"provider": "postgresql",
"cacheEnabled": true,
"cacheTTL": 3600,
"maxMemorySize": "100MB",
"embeddings": {
"enabled": true,
"model": "text-embedding-ada-002"
}
}
}Best Practices
Privacy: Respect user privacy, allow data deletion
Retention: Set appropriate data retention periods
Relevance: Store only relevant information
Performance: Use caching for frequently accessed data
Security: Encrypt sensitive information
Next Steps
Need Help?
Last updated

