integrations/google-adk/v0.1.0

altic-dev/FluidVoiceintegrations/google-adk/v0.1.0Sep 28, 2026by het0814

Upgrading?

AI Summary

First release of the Google ADK integration for Memanto.

Key Highlights

  • MemantoMemoryService implementation
  • Typed memories through Memanto's extraction
  • Per-user memory scoping
  • Optional `remember_tool` support

New Features

  • Google ADK integration
  • MemantoMemoryService
  • Typed memories

Full Release Notes

# Release Notes for google-adk v0.1.0

First release of **`memanto-google-adk`**, a persistent long-term memory backend for Google ADK agents. The package implements ADK's `BaseMemoryService`, so ADK's own `preload_memory` and `load_memory` tools read from Memanto without changes. Conversations are stored as typed memories rather than raw transcripts, each ADK user's memories are private, and saving a session many times stores each turn only once. It also works with `adk web`, `adk api_server` and `adk run` through a `memanto://` service URI.

## New Features
- **`MemantoMemoryService`, a drop-in ADK memory backend** (`integrations/google-adk/memanto_google_adk/memory.py`)
  - Implements all four `BaseMemoryService` methods: `add_session_to_memory`, `add_events_to_memory`, `add_memory` and `search_memory`.
  - Enabled with `Runner(..., memory_service=MemantoMemoryService())`. The API key comes from `$MOORCHEH_API_KEY` or `api_key=`.
  - Options: `agent_id`, `recall_limit` (1–100, default 10) and `extract_max_memories` (1–100, default 20), checked when the service is created.
- **Typed memories through Memanto's extraction** (`memanto_google_adk/memory.py`)
  - New user and agent text is run through `ConversationMemoryExtractionService` and stored as typed memories (preference, fact, decision, commitment…); small talk is dropped.
  - Tool calls, tool results, partial streaming events and turns without user speech are skipped.
  - Long backlogs are split into chunks that fit the extractor's 200-message and 120k-character limits instead of being cut off.
- **Each turn stored once, even across processes** (`memanto_google_adk/memory.py`)
  - Each stored batch carries a `retained-<hash>` marker for the last event it covered. The next `add_session_to_memory` extracts only later events, even from a different process, so calling it after every turn is safe.
  - A retried `add_events_to_memory` call with the same events stores nothing.
  - If a save fails part-way, the next save resumes after the last chunk that was stored, so turns missed during a Memanto outage are picked up automatically.
- **Per-user memory scoping** (`memanto_google_adk/memory.py`)
  - One Memanto agent per ADK app (`adk-<app_name>`, created on first use). Pass `agent_id=` to share one agent across apps.
  - Every memory is tagged `user-<sha256 of user_id>`. The user is taken from ADK's session, never from the model, and every recall result is checked against the tag again, so a missed tag filter on the backend cannot show one user another user's memories.
- **ADK-native search results** (`memanto_google_adk/memory.py`)
  - `search_memory` returns ADK `MemoryEntry` objects with `timestamp`, plus `custom_metadata` carrying `type`, `title`, `confidence`, `provenance`, `tags` and `score`. Only active memories are returned; an empty query returns nothing without calling Memanto.
- **`add_memory` for explicit writes** (`memanto_google_adk/memory.py`)
  - Stores `MemoryEntry` items as they are, without extraction. `custom_metadata["type"]` sets the Memanto type (default `fact`).
  - Large writes are sent in slices of `batch_remember`'s 100-item limit, and memories Memanto rejects are logged instead of silently dropped.
- **`remember_tool` / `memanto_remember`** (`integrations/google-adk/memanto_google_adk/tools.py`)
  - An optional ADK `FunctionTool` that lets the agent save a fact as soon as it hears one. It writes through `tool_context.add_memory`, so the app and user come from ADK and the model cannot choose whose memory it writes.
- **`adk web` / `adk run` support** (`memanto_google_adk/memory.py`)
  - `MemantoMemoryService.from_uri` registers as a service-registry factory for `memanto://` (one agent per app) or `memanto://<agent_id>` (one shared agent).
- **Session reuse and recovery** (`memanto_google_adk/memory.py`)
  - Each Memanto agent keeps its own client and activates once; the service re-activates once on a `SessionError`.
  - SDK calls run in `asyncio.to_thread` so they don't block ADK's event loop.
- **Packaging** (`integrations/google-adk/pyproject.toml`)
  - Published as `memanto-google-adk`. Requires Python 3.10+, `memanto>=0.2.21` and `google-adk>=2.0,<3`. The ADK major version is capped so a future ADK 3.0 cannot break existing installs.

## Tests
- `integrations/google-adk/tests/test_google_adk.py`: 20 tests against a fake Memanto client, covering:
  - user isolation when the backend tag filter misses
  - agent ID sanitization
  - incremental and cross-process saves, and retry idempotency
  - chunking of long sessions and resuming after a chunk fails
  - 100-item batch slicing and logging of rejected items
  - validation of settings
  - end-to-end ADK `Runner` flows: `remember_tool` → `preload_memory` in a new session, and the README's `after_agent_callback` surviving a Memanto outage and catching up on the next turn
- Passes on ADK 2.0.0 and 2.10.0, and on Python 3.10.

## Full Changelog
Full Changelog: https://github.com/moorcheh-ai/memanto/compare/v0.2.24...integrations/google-adk/v0.1.0

Related Repositories