Add persistent memory to Google Agent Development Kit agents.

Google ADK Integration

Google's Agent Development Kit gives agents tools and orchestration. Register CortexDB recall + capture as ADK tools and the agent picks them up automatically.

Install

pip install cortexdbai[google-adk]

Memory tools

import os
from cortexdb import Cortex
from cortexdb.integrations.google_adk import get_cortexdb_tools
from google.adk import Agent

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

tools = get_cortexdb_tools(client, scope="org:acme/user:alice")
agent = Agent(name="memory_agent", tools=tools)

Individual factories cortexdb_store_tool, cortexdb_search_tool, cortexdb_forget_tool (each (client, scope=...)) are also exported.

Prefer manual control?

import os
from datetime import datetime, timezone
from uuid import uuid4
from google.adk.agents import LlmAgent
from google.adk.tools import FunctionTool
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"


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


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


agent = LlmAgent(
    name="memory_agent",
    model="gemini-2.0-flash",
    instruction="Recall before answering; capture after each turn.",
    tools=[FunctionTool(recall_long_term), FunctionTool(capture)],
)

See also