Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions contributing/samples/synap_memory_agent/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Synap Memory Agent Sample

This sample demonstrates how to add persistent, cross-session memory to a Google ADK agent using [Synap](https://maximem.ai) — a managed long-term memory layer for AI agents.

## What it does

The agent is wired up with two `FunctionTool` instances from `maximem-synap-google-adk`:
- `search_memory` — semantic search over the user's stored memories
- `store_memory` — persist explicit facts the user mentions

On each turn the agent can recall what it knows about the user and save new facts for future sessions.

## Setup

```bash
pip install maximem-synap-google-adk maximem-synap
export SYNAP_API_KEY=<your-key> # free key at https://synap.maximem.ai
```

## Run

```bash
adk run contributing/samples/synap_memory_agent
```

Try teaching it something on the first turn (e.g. *"I'm allergic to peanuts"*), then ask about it on a later turn — Synap will retrieve the relevant memory automatically.

## Resources

- [Synap documentation](https://docs.maximem.ai)
- [PyPI: `maximem-synap-google-adk`](https://pypi.org/project/maximem-synap-google-adk/)
- [Open source integration package](https://github.com/maximem-ai/maximem_synap_sdk/tree/main/packages/integrations/synap-google-adk)
15 changes: 15 additions & 0 deletions contributing/samples/synap_memory_agent/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from . import agent
54 changes: 54 additions & 0 deletions contributing/samples/synap_memory_agent/agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Sample agent demonstrating Synap memory tools.

Synap (https://maximem.ai) is a managed long-term memory layer for AI agents.
The `maximem-synap-google-adk` package exposes Synap as ADK FunctionTools so
the agent can search and store memories across sessions.

Setup:
pip install maximem-synap-google-adk maximem-synap
export SYNAP_API_KEY=<your-key> # https://synap.maximem.ai

Open source integration package:
https://github.com/maximem-ai/maximem_synap_sdk/tree/main/packages/integrations/synap-google-adk
"""

import os

from google.adk.agents.llm_agent import Agent
from maximem_synap import MaximemSynapSDK
from synap_google_adk import create_synap_tools

# Initialize the Synap SDK once at module load.
sdk = MaximemSynapSDK(api_key=os.environ["SYNAP_API_KEY"])

# `create_synap_tools` returns [search_memory, store_memory] FunctionTool instances.
synap_tools = create_synap_tools(
sdk=sdk,
user_id="demo-user-001",
customer_id="demo-customer",
)

root_agent = Agent(
model="gemini-2.0-flash",
name="memory_assistant",
instruction=(
"You are a helpful assistant with long-term memory. "
"Use search_memory to recall what you know about the user. "
"Use store_memory to save important new facts the user mentions."
),
tools=synap_tools,
)