Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs-omnicoreagent.omnirexfloralabs.com/llms.txt

Use this file to discover all available pages before exploring further.

Multi-Tier Memory System

Runtime-switchable memory backends — start in memory, switch to Redis, MongoDB, or SQL database storage when the application needs persistence.

Quick Start

The default in_memory backend is enough for local development and tests:
import asyncio
from omnicoreagent import OmniCoreAgent, MemoryRouter

async def main():
    agent = OmniCoreAgent(
        name="memory_agent",
        system_instruction="Remember useful details inside the active session.",
        model_config={"provider": "openai", "model": "gpt-4o"},
        memory_router=MemoryRouter("in_memory"),
    )

    await agent.run("My project is called Atlas.", session_id="user_123")
    result = await agent.run("What is my project called?", session_id="user_123")
    print(result["response"])
    await agent.cleanup()

asyncio.run(main())
Install the backend extra before using a durable store:
pip install "omnicoreagent[redis]"
pip install "omnicoreagent[mongodb]"
pip install "omnicoreagent[postgres]"
from omnicoreagent import OmniCoreAgent, MemoryRouter

# Start with Redis
agent = OmniCoreAgent(
    name="my_agent",
    system_instruction="Remember useful details inside the active session.",
    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("sql")         # Switch to SQL database storage
await agent.switch_memory_store("in_memory")   # Switch to in-memory
await agent.switch_memory_store("redis")       # Back to Redis

Available Backends

BackendUse CaseEnvironment Variable
in_memoryFast development
redisProduction persistenceREDIS_URL
sqlSQLAlchemy database storageDATABASE_URL
mongodbDocument storageMONGODB_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

memory_router = MemoryRouter("redis")

memory_config = {
    "mode": "sliding_window",  # or "token_budget"
    "value": 10,  # Keep last 10 messages, or max tokens in token_budget mode
    "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"},
    agent_config={"memory_config": memory_config},
)

Summarization Modes

ModeDescriptionBest For
sliding_windowKeep last N messages, summarize older onesPredictable memory size
token_budgetKeep messages within token limitCost optimization

Retention Policies

PolicyBehavior
keepMark summarized messages as inactive (recoverable)
deletePermanently remove summarized messages

How It Works

  1. When conversation exceeds configured limit → summarization triggers
  2. Older messages are sent to LLM for summary generation
  3. Summary replaces older messages in active context
  4. 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.