diff --git a/contributing/samples/synap_memory_agent/README.md b/contributing/samples/synap_memory_agent/README.md new file mode 100644 index 0000000000..0f84f7cc34 --- /dev/null +++ b/contributing/samples/synap_memory_agent/README.md @@ -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= # 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) diff --git a/contributing/samples/synap_memory_agent/__init__.py b/contributing/samples/synap_memory_agent/__init__.py new file mode 100644 index 0000000000..4015e47d6e --- /dev/null +++ b/contributing/samples/synap_memory_agent/__init__.py @@ -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 diff --git a/contributing/samples/synap_memory_agent/agent.py b/contributing/samples/synap_memory_agent/agent.py new file mode 100644 index 0000000000..688fdaec79 --- /dev/null +++ b/contributing/samples/synap_memory_agent/agent.py @@ -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= # 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, +)