Expose Synap memory to an AutoGen agent 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.
BaseTool implementations. The agent decides when to call each — and both tools cooperate with AutoGen’s CancellationToken so a long search can be aborted mid-flight.
Overview
This guide shows how to add Synap to an AutoGen application to build agents that:- Recall user-specific facts, preferences, and past conversations
- Persist new information surfaced during a conversation
- Respect AutoGen’s cooperative cancellation model so memory calls don’t leak past a cancelled task
BaseTool interface.
| Class | AutoGen interface | Purpose |
|---|---|---|
SynapSearchTool | BaseTool | Searches Synap memory by natural-language query |
SynapStoreTool | BaseTool | Stores a new memory in Synap |
Setup
Install the package alongside AutoGen:.env
Basic integration
The smallest useful integration registers both tools on anAssistantAgent and runs a task. The agent reads tool descriptions and decides whether to search or store:
user_id, optional customer_id) is bound at construction — the model only ever sees query, max_results, and mode, never the user identity. This prevents prompt-injection attempts from spoofing scope.
Core concepts
Search tool
SynapSearchTool is the read side. The model can override max_results and mode per call but cannot reach outside the scope bound at construction.
content, type, and confidence fields.
The two retrieval modes trade latency against comprehensiveness:
fast | accurate | |
|---|---|---|
| Latency | 50-100ms | 200-500ms |
| Search | Vector similarity | Vector + graph + re-ranking |
| Best for | Real-time chat | Multi-entity queries |
[] and logs an error so the agent can continue.
Store tool
SynapStoreTool is the write side. The model supplies the content and an optional memory type; everything else is fixed at construction.
{"status": "stored", "id": "..."} on success. Store failures surface explicitly — the tool raises SynapIntegrationError so the agent (and you) know if persistence failed.
Cooperative cancellation
Both tools propagate AutoGen’sCancellationToken. When the token is cancelled, the in-flight Synap call is aborted and the tool returns control to the agent rather than continuing to completion:
Complete example: assistant team with shared memory
The following team has two agents sharing the same Synap-backed memory: aResearcher that searches and stores, and a Planner that searches but never stores. Both run inside an AutoGen RoundRobinGroupChat:
- Scope is per-tool, per-agent. Both agents see the same user’s memory, but only the
Researchercan write. This is a common safety pattern — minimize the surface that can mutate memory. - Memory is shared across agents. Anything
Researcherstores during this run is immediately available toPlanneron the next turn. CancellationTokenflows automatically through AutoGen’s task group, so cancelling the team also cancels any in-flight Synap calls.
Advanced patterns
Multi-tenant scoping
Both tools accept 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.
Tuning retrieval mode
The model can passmode: "accurate" for higher-recall, slower lookups. For a global default, configure your system prompt to specify the mode the agent should prefer — the tool will respect whatever the model passes.
Failure semantics
The integration follows the Synap-wide contract:SynapSearchTooldegrades gracefully — returns[]and logs an errorSynapStoreToolsurfaces failures — raisesSynapIntegrationErrorso the agent and caller know persistence failed- Cancellation is honored — both tools abort cleanly when
CancellationToken.cancel()fires
Next steps
OpenAI Agents
Function tools for the OpenAI Agents SDK.
CrewAI
Storage backend for CrewAI crews.
Context Fetch
The retrieval API behind
SynapSearchTool — modes, scopes, and response shapes.Memory Scopes
How
user_id and customer_id interact across reads and writes.