Give OpenClaw — Claude-powered desktop agents — durable memory across machines and sessions.

OpenClaw Integration

OpenClaw is a Claude-powered desktop agent (eyes + hands on your screen). CortexDB gives it memory that survives across machines and restarts.

Install

pip install cortexdbai openclaw

Pattern

import os
from datetime import datetime, timezone
from uuid import uuid4
from openclaw import Agent, register_tool
from cortexdb.v1 import V1Client

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


@register_tool
def recall_long_term(query: str) -> str:
    """Recall prior context from long-term memory across machines."""
    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)"


@register_tool
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"oc-{role}-{uuid4()}")
    return "captured"


agent = Agent()

Why CortexDB for OpenClaw

A desktop coworker is useless if it forgets every restart. CortexDB's bi-temporal model lets OpenClaw correctly recall what was true on the user's machine on Tuesday even after the screen state has changed — see Bi-temporal queries.

See also