> ## Documentation Index
> Fetch the complete documentation index at: https://docs.memanto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Google ADK

> Persistent long-term memory for Google ADK agents: a drop-in ADK memory service backed by Memanto.

# Google ADK + Memanto

<img src="https://mintcdn.com/memanto/KIiY92bJoc-XiGzw/logo/integrations/google-adk.png?fit=max&auto=format&n=KIiY92bJoc-XiGzw&q=85&s=e371e4b1591660bc6bd436a24aa19faf" alt="Google ADK" width="64" style={{marginBottom: "1.5rem"}} data-path="logo/integrations/google-adk.png" />

A [Google ADK](https://google.github.io/adk-docs/) agent forgets everything when its session ends. ADK's built-in `InMemoryMemoryService` is lost on restart, and Vertex AI Memory Bank ties you to Google Cloud.

**`memanto-google-adk`** is a drop-in ADK memory service backed by Memanto.

<CardGroup cols={2}>
  <Card title="Works with ADK's own tools" icon="plug">
    `MemantoMemoryService` implements ADK's `BaseMemoryService`, so `preload_memory` and `load_memory` read from Memanto unchanged.
  </Card>

  <Card title="Typed memories, not transcripts" icon="brain">
    Saved turns go through Memanto's extraction: preferences, facts, decisions and commitments are kept; small talk is dropped.
  </Card>

  <Card title="Private per user" icon="user-lock">
    Every memory is tagged with its ADK user, and results are re-checked against that tag before they are returned.
  </Card>

  <Card title="Save every turn, store once" icon="clone">
    Each save extracts only events added since the last one, across processes, and a retried save stores nothing.
  </Card>
</CardGroup>

## How It Works

```text theme={null}
Agent turn ends    →  after_agent_callback  →  add_session_to_memory  →  extract new events  →  Memanto
                                                                                                  │
Next user message  →  preload_memory / load_memory  →  search_memory (this user only)  ←──────────┘
                                                                                                  │
User states a fact →  memanto_remember tool  →  add_memory  ─────────────────────────────────────┘
```

Everything lives in a Memanto agent, so you can read, correct, and audit what your ADK agent knows with the [CLI](/cli/overview) or the web UI.

## Prerequisites

* Python **3.10+**
* `google-adk` **2.0+**
* Memanto **0.2.21+** and a [Moorcheh API key](https://console.moorcheh.ai/api-keys) (or an on-prem Memanto backend)

## Install

```bash theme={null}
pip install memanto-google-adk
export MOORCHEH_API_KEY=your_key_xxxxxxxxxxxxxxxxxx
```

Until `memanto-google-adk` is on PyPI, install it from a checkout of the Memanto repo: `pip install ./integrations/google-adk` (see [GitHub source](https://github.com/moorcheh-ai/memanto/tree/main/integrations/google-adk)).

## Use it

```python theme={null}
import logging

from google.adk.agents import LlmAgent
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService
from google.adk.tools import preload_memory
from memanto_google_adk import MemantoMemoryService, remember_tool


async def save_to_memory(callback_context):
    # Store what is new in this session after every agent turn. If Memanto is
    # unreachable, log it rather than fail the user's turn: the next
    # successful save picks up the turns this one missed.
    try:
        await callback_context.add_session_to_memory()
    except Exception:
        logging.exception("Saving to Memanto failed")


agent = LlmAgent(
    name="travel_agent",
    model="gemini-2.5-flash",
    instruction="You are a travel assistant.",
    tools=[preload_memory, remember_tool],
    after_agent_callback=save_to_memory,
)

runner = Runner(
    app_name="travel",
    agent=agent,
    session_service=InMemorySessionService(),
    memory_service=MemantoMemoryService(),
)
```

* **`preload_memory`** recalls memories that match the user's message and adds them to every request. Use **`load_memory`** instead if the model should decide when to look things up.
* **`remember_tool`** is optional. Memories are extracted from saved sessions anyway, but the tool lets the agent save a fact the moment it hears it.
* **`after_agent_callback`** is where saving happens. Calling it every turn is safe: only new events are extracted.

<Note>
  Extraction is one LLM call per save. To keep it off the response path, run the save as a background task.
</Note>

### With `adk web` / `adk run`

Register the `memanto://` scheme in a `services.py`:

```python theme={null}
from google.adk.cli.service_registry import get_service_registry
from memanto_google_adk import MemantoMemoryService

get_service_registry().register_memory_service("memanto", MemantoMemoryService.from_uri)
```

Where ADK looks for it depends on the command:

| Command | `services.py` goes in |
| - | - |
| `adk web --memory_service_uri memanto:// <agents_dir>` (also `adk api_server`) | `<agents_dir>/services.py`, the folder that contains your agent folders |
| `adk run --memory_service_uri memanto:// <agents_dir>/my_agent` | `<agents_dir>/my_agent/services.py` |

A `services.py` in the wrong folder fails at startup with `Unsupported memory service URI: memanto:`. Set `MOORCHEH_API_KEY` in the environment before starting.

`memanto://my-agent` uses the Memanto agent `my-agent` for every app, instead of one per app.

## How memory is scoped

| | |
| - | - |
| **One Memanto agent per ADK app** | Named `adk-<app_name>`, with characters other than letters, digits, `-` and `_` replaced by `-`. The agent is created on first use. Pass `agent_id=` to share one Memanto agent across several apps. |
| **Private per ADK user** | Every memory is tagged `user-<sha256 of user_id>` and recall filters by that tag. The user comes from ADK's session, never from the model, and every result is re-checked against the tag, so one user never sees another's memories. |
| **Incremental saves** | Stored memories carry a `retained-` marker for the last event they covered. The next save extracts only later events, even from a different process, and a retried save stores nothing. |

## API

| | |
| - | - |
| `MemantoMemoryService(api_key=None, *, agent_id=None, recall_limit=10, extract_max_memories=20)` | The memory service. `api_key` defaults to `$MOORCHEH_API_KEY`; `recall_limit` is 1–100. |
| `add_session_to_memory(session)` | Extracts and stores events added since the last save. |
| `add_events_to_memory(app_name=, user_id=, events=, session_id=None)` | Extracts and stores a delta, such as the latest turn. |
| `add_memory(app_name=, user_id=, memories=)` | Stores `MemoryEntry` items as they are, without extraction. `custom_metadata["type"]` sets the [memory type](/reference/memory-types) (default `fact`). |
| `search_memory(app_name=, user_id=, query=)` | Semantic recall of this user's active memories. Each `MemoryEntry` has `timestamp`, and `custom_metadata` with `type`, `title`, `confidence`, `provenance`, `tags` and `score`. |
| `MemantoMemoryService.from_uri(uri)` | Factory for ADK's service registry: `memanto://` or `memanto://<agent_id>`. |
| `remember_tool` / `memanto_remember(content, memory_type)` | ADK tool that saves one memory through `tool_context.add_memory`. |

## Behavior and limits

| Behavior | Detail |
| - | - |
| **One session per agent** | Activating a Memanto agent signs out every other client of it. Several processes serving the same app take turns re-activating (the service retries once on a session error), which works but adds latency. Prefer one worker per agent. |
| **Text only** | User and agent text is extracted; tool calls, tool results, and partial streaming events are skipped. Turns without user speech store nothing. |
| **Nothing worth keeping** | If extraction finds nothing durable in a turn, nothing is stored. |
| **Active memories only** | `search_memory` returns only active memories. |

## Shared memory across integrations

All Memanto integration packages use the same Moorcheh-backed agents when they share an `agent_id`:

| Integration | Package | What it does |
| - | - | - |
| **Google ADK** | `memanto-google-adk` | ADK `BaseMemoryService` plus a remember tool. |
| [`integrations/pydantic-ai`](/integrations/pydantic-ai) | `memanto-pydantic-ai` | Automatic recall into instructions, plus tools for remember, recall, and answer. |
| [`integrations/eve`](/integrations/eve) | `@moorcheh-ai/memanto/eve` | Eve tools for recall, remember, and answer. |
| [`integrations/mcp`](/integrations/mcp) | `memanto-mcp` | MCP server for Claude Desktop, Cursor, etc. |
| [`integrations/vapi`](/integrations/vapi) | `memanto-vapi` | Webhook giving a Vapi voice agent knowledge, lessons, and optional per-caller memory. |
| [`integrations/crewai`](/integrations/crewai) | `crewai-memanto` | CrewAI tools for multi-agent memory. |
| [`integrations/langgraph`](/integrations/langgraph) | `langgraph-memanto` | LangGraph `BaseStore`, nodes, and tools. |

## Next Steps

* [Google ADK integration source & README](https://github.com/moorcheh-ai/memanto/tree/main/integrations/google-adk)
* [ADK memory docs](https://google.github.io/adk-docs/sessions/memory/)
* [Remember API](/api-reference/data/remember)
* [Recall API](/api-reference/search/recall)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.