Multi-Tier Memory System
5 backends with runtime switching — start with Redis, switch to MongoDB, then PostgreSQL — all on the fly!
Quick Start
from omnicoreagent import OmniCoreAgent, MemoryRouter
# Start with Redis
agent = OmniCoreAgent(
name="my_agent",
memory_router=MemoryRouter("redis"),
model_config={"provider": "openai", "model": "gpt-4o"}
)
# Switch at runtime — no restart needed!
await agent.switch_memory_store("mongodb") # Switch to MongoDB
await agent.switch_memory_store("database") # Switch to PostgreSQL/MySQL/SQLite
await agent.switch_memory_store("in_memory") # Switch to in-memory
await agent.switch_memory_store("redis") # Back to Redis
Available Backends
| Backend | Use Case | Environment Variable |
|---|
in_memory | Fast development | — |
redis | Production persistence | REDIS_URL |
database | PostgreSQL/MySQL/SQLite | DATABASE_URL |
mongodb | Document storage | MONGODB_URI |
Conversation Summarization
OmniCoreAgent includes automatic conversation summarization to manage long conversation histories efficiently. When enabled, older messages are condensed into summaries, keeping context while reducing token usage.
from omnicoreagent import OmniCoreAgent, MemoryRouter
# Configure summarization with sliding window
memory_router = MemoryRouter(
store_type="redis",
memory_config={
"mode": "sliding_window", # or "token_budget"
"value": 10, # Keep last 10 messages (sliding_window) or max tokens (token_budget)
"summary": {
"enabled": True,
"retention_policy": "keep" # Options: "keep" or "delete"
}
}
)
agent = OmniCoreAgent(
name="summarizing_agent",
memory_router=memory_router,
model_config={"provider": "openai", "model": "gpt-4o"}
)
Summarization Modes
| Mode | Description | Best For |
|---|
sliding_window | Keep last N messages, summarize older ones | Predictable memory size |
token_budget | Keep messages within token limit | Cost optimization |
Retention Policies
| Policy | Behavior |
|---|
keep | Mark summarized messages as inactive (recoverable) |
delete | Permanently remove summarized messages |
How It Works
- When conversation exceeds configured limit → summarization triggers
- Older messages are sent to LLM for summary generation
- Summary replaces older messages in active context
- Original messages are retained (with
"keep") or deleted per policy
Enable summarization for long-running conversations (support bots, research assistants) to maintain context while controlling costs. Use sliding_window for predictable behavior, token_budget for strict cost control.