Use CortexDB as a long-term memory provider for NousResearch Hermes agents.

Hermes Integration

NousResearch's Hermes Agent uses tool-calling for memory. Register CortexDB recall and capture as tools the model can invoke.

Install

pip install cortexdbai hermes-agent

Pattern

import os
from datetime import datetime, timezone
from uuid import uuid4
from hermes_agent import Agent, tool
from cortexdb.v1 import V1Client

client = V1Client(api_url="https://api-v1.cortexdb.ai", actor="user:alice",
                  bearer=os.environ["CORTEX_TOKEN"])
SCOPE = "org:acme/user:alice"


@tool(name="recall_long_term", description="Recall prior context from long-term memory.")
def recall_long_term(query: str) -> str:
    pack = client.recall(scope=SCOPE, view="holistic", query=query,
                         include=["beliefs", "facts", "episodes"],
                         budgets={"max_tokens": 3000})
    return pack["context_block"] or "(no relevant context)"


@tool(name="capture", description="Capture a turn into long-term memory.")
def capture(text: str, role: str = "assistant") -> str:
    client.experience(scope=SCOPE, text=text, role=role,
                      observed_at=datetime.now(timezone.utc).isoformat(),
                      idempotency_key=f"hermes-{role}-{uuid4()}")
    return "captured"


agent = Agent(tools=[recall_long_term, capture])

See also