Memory enables agents to maintain context within conversations and learn from past interactions. Understanding memory is key to building effective, context-aware agents.
RealAroha agents use a multi-tiered memory system that balances performance, cost, and capability:
Scope: Current conversation/session
Duration: Until session ends
Capacity: Model's context window (up to 200K tokens)
Use case: Multi-turn conversations, task continuity
Scope: Across all conversations
Duration: Indefinite (until deleted)
Capacity: Unlimited (vector database)
Use case: User preferences, learned patterns, facts
Scope: Historical conversations
Duration: Configurable retention
Capacity: Summarized episodes
Use case: Referencing past interactions
Scope: Shared knowledge base
Duration: Permanent
Capacity: RAG-indexed documents
Use case: Product info, policies, FAQs
Short-term memory is the conversation history passed to the model with each request. It enables agents to understand context and maintain coherent conversations.
{
"memoryConfig": {
"shortTerm": {
"enabled": true,
"maxMessages": 50, // Max conversation turns to keep
"maxTokens": 100000, // Token budget for history
"strategy": "sliding", // sliding | summary | hybrid
// Sliding window options
"slidingWindow": {
"keepSystemPrompt": true,
"keepFirstN": 2, // Always keep first N messages
"keepLastN": 20 // Always keep last N messages
},
// Summary options (for long conversations)
"summarization": {
"enabled": true,
"triggerAt": 30, // Summarize after N messages
"keepOriginal": 5 // Keep last N originals after summary
}
}
}
}Long-term memory persists across conversations, enabling agents to remember user preferences, learn from interactions, and access organizational knowledge.
{
"memoryConfig": {
"longTerm": {
"enabled": true,
"storage": "vector", // vector | relational | hybrid
"vectorStore": {
"provider": "pinecone", // pinecone | qdrant | weaviate
"namespace": "agent-memory",
"dimensions": 1536,
"similarity": "cosine"
},
"retrieval": {
"topK": 5, // Number of memories to retrieve
"minScore": 0.7, // Minimum similarity threshold
"reranking": true // Use cross-encoder reranking
},
"storage": {
"autoSave": true, // Automatically save important info
"saveThreshold": 0.8, // Importance threshold for saving
"deduplication": true // Prevent duplicate memories
},
"categories": [
"user_preferences",
"facts",
"instructions",
"feedback"
]
}
}
}await agent.memory.store({
content: "User prefers formal tone",
category: "user_preferences",
metadata: {
userId: "user_123",
confidence: 0.9
}
});const memories = await agent.memory.retrieve({
query: "What tone does user prefer?",
category: "user_preferences",
userId: "user_123",
topK: 3
});When agents work together, they can share memory through the Shared Context system:
// Coordinator agent saves context for specialist
await coordinator.sharedContext.set({
key: "campaign_brief",
value: {
tone: "professional",
audience: "first-home-buyers",
keyPoints: ["affordability", "location", "potential"]
},
scope: "workflow",
ttl: 3600
});
// Specialist agent retrieves shared context
const brief = await specialist.sharedContext.get("campaign_brief");
// Agent now knows the campaign requirementsNote: Shared context is different from agent memory. See Shared Context for details on inter-agent communication.