Add persistent, per-user memory to a Google ADK agent in one factory call. Synap exposes itself as twoDocumentation Index
Fetch the complete documentation index at: https://docs.maximem.ai/llms.txt
Use this file to discover all available pages before exploring further.
FunctionTool instances — the agent decides when to recall or remember.
Overview
This guide shows how to add Synap to a Google ADK application to build agents that:- Recall user-specific facts, preferences, and past conversations
- Persist new information surfaced during a conversation
- Stay multi-user-safe by binding scope at tool construction
FunctionTool instances ready to drop onto an Agent.
| Export | Returns | Purpose |
|---|---|---|
create_synap_tools | [search_memory, store_memory] | Two ADK FunctionTool instances for memory recall and storage |
Setup
Install the package alongside the Google ADK:.env
Basic integration
The smallest useful integration callscreate_synap_tools and passes the result straight into an Agent. The factory returns a list, so it fits the tools= parameter without unpacking:
user_id and customer_id into the closures it returns — the model only ever sees query, max_results, and content, never the user identity. This prevents prompt-injection attempts from spoofing scope.
Core concepts
create_synap_tools
create_synap_tools returns a two-element list: [search_memory, store_memory]. Both are ADK FunctionTool instances and can be passed directly to Agent(tools=...):
search_memory
Tool signature exposed to the model:{"content": "...", "type": "...", "confidence": float}. The agent sees this as JSON and can reason over it directly.
Search failures degrade gracefully — the tool returns [] and logs an error so the agent continues without recall rather than aborting.
store_memory
Tool signature exposed to the model:{"status": "stored", "id": "..."} on success. Store failures surface explicitly — the tool raises SynapIntegrationError so the agent (and you) know if persistence failed.
Complete example: per-user memory agent
In a multi-user service, build a fresh tool set per request. Each agent run gets a scope-bound tool list, so two concurrent users cannot see each other’s memories:- Per-request agent construction is the safety pattern. Each request gets its own scope-bound tool list — no shared state can leak between users.
- The instruction is the policy. Telling the model to always call
search_memoryfirst is what produces recall behavior; the tools are just plumbing. - Failure modes split. Search is best-effort (empty list on failure); store is strict (raises on failure) so silent data loss is impossible.
Advanced patterns
Multi-tenant scoping
create_synap_tools accepts the standard scoping triple — user_id (required), optional customer_id, optional conversation_id. customer_id is required on B2B Synap instances and ignored on single-tenant ones. See Memory Scopes.
Multi-agent setups
EachAgent can carry its own tool list. Give a “memory-keeper” agent both tools and a “consumer” agent only search_memory to keep the write surface small:
Failure semantics
The integration follows the Synap-wide contract:search_memorydegrades gracefully — returns[]and logs an error if Synap is unreachable.store_memorysurfaces failures — raisesSynapIntegrationErrorso the agent and caller know persistence failed.
Next steps
Haystack
Pipeline components for Haystack.
Agno
InMemoryDb replacement for Agno agents.Context Fetch
The retrieval API behind
search_memory — modes, scopes, and response shapes.Memory Scopes
How
user_id and customer_id interact across reads and writes.