Skip to content

Agent frameworks

Google ADK

SurrealDB Agent Memory gives Google ADK agents persistent memory that survives restarts and separate conversations. The package wraps SurrealDB Agent Memory's verbs as ADK tools; it handles entity extraction, knowledge-graph storage, temporal facts, and hybrid retrieval.

Package: agent-memory-google-adk (PyPI). It pulls in google-adk and surrealdb.

pip install agent-memory-google-adk

This pulls in google-adk and surrealdb (the SurrealDB Agent Memory client ships in surrealdb 3.0.0a1 and later, installed automatically).

The SurrealDB Agent Memory SDK does not read the environment itself. You pass the values in explicitly, or use AgentMemoryConfig.from_env() to read them for you:

export AGENT_MEMORY_CONTEXT="acme-prod"
export AGENT_MEMORY_ENDPOINT="https://api.agent-memory.example"
export AGENT_MEMORY_API_KEY="sk-spec-..."
export GOOGLE_API_KEY="your-google-api-key"   # used by the ADK model

AgentMemoryToolset extends ADK's BaseToolset, so an ADK Runner closes it on shutdown:

import asyncio
from google.adk.agents import Agent
from google.adk.runners import InMemoryRunner
from agent_memory_google_adk import AgentMemoryToolset

async def main():
    toolset = AgentMemoryToolset(
        context="acme-prod",
        endpoint="https://api.agent-memory.example",
        api_key="sk-spec-...",
    )

    agent = Agent(
        model="gemini-2.5-flash",
        name="assistant",
        description="An assistant with persistent memory.",
        instruction="Store durable facts with remember and look things up with recall.",
        tools=[toolset],
    )

    runner = InMemoryRunner(agent=agent)
    try:
        await runner.run_debug("Remember: Acme Corp, healthcare, 1.2M dollar contract.")
        events = await runner.run_debug("What healthcare contracts do we have?")
        for event in events:
            if event.is_final_response() and event.content:
                for part in event.content.parts:
                    if part.text:
                        print(part.text)
    finally:
        await runner.close()
        await toolset.close()

asyncio.run(main())

AgentMemoryToolset (recommended) owns the client and manages its lifecycle. Add it as a single item in the tools list:

toolset = AgentMemoryToolset(config=AgentMemoryConfig.from_env())
agent = Agent(model="gemini-2.5-flash", name="assistant", tools=[toolset])

get_agent_memory_tools returns a plain list of tools for quick scripts. Pass your own client to control its lifecycle:

from surrealdb.memory import AsyncMemory
from agent_memory_google_adk import get_agent_memory_tools

client = AsyncMemory(context="acme-prod", endpoint="...", api_key="sk-...")
tools = get_agent_memory_tools(client=client)

Bind a session_id (and optionally a scope) when you build the tools. Both are fixed at build time and are not exposed to the model, so an agent cannot read or write outside its slice of memory:

toolset = AgentMemoryToolset(config=config, session_id="user-123")

Two agents built with the same session_id share memory; different session ids stay isolated.

All verbs are available by default. Pass include=[...] to narrow them, for example a collector agent that can only write and a researcher that can only read:

collector = AgentMemoryToolset(config=config, include=["remember"])
researcher = AgentMemoryToolset(config=config, include=["recall", "reflect"])

The verbs are remember, recall, forget, reflect, chat, consolidate, elaborate, query_context, inspect, and state. Every tool returns a JSON-safe dict with a status of "success" or "error", so a failed request reaches the model as data rather than failing the agent turn.

  • For an MCP-native host, use the MCP server.

  • To call SurrealDB Agent Memory directly, use the Python SDK.

Was this page helpful?