Add persistent, per-user memory to a Semantic Kernel application as a single plugin. Both kernel functions (Documentation Index
Fetch the complete documentation index at: https://docs.maximem.ai/llms.txt
Use this file to discover all available pages before exploring further.
search_memory and store_memory) are auto-invokable, so the kernel can decide when to query or persist memories on its own.
Overview
This guide shows how to add Synap to a Semantic Kernel application to build kernels that:- Recall user-specific facts, preferences, and past conversations
- Persist new information surfaced during a conversation
- Auto-invoke memory functions when the model decides they are relevant
| Export | SK interface | Purpose |
|---|---|---|
SynapPlugin | Kernel plugin | Provides search_memory and store_memory kernel functions |
Setup
Install the package alongside Semantic Kernel:.env
Basic integration
The smallest useful integration addsSynapPlugin to a kernel and invokes a prompt that references the plugin’s functions:
user_id, optional customer_id) is bound when you construct the plugin — the kernel functions only ever see query, content, and other model-supplied parameters. This prevents prompts (or prompt injections) from spoofing scope.
For automatic invocation (the kernel chooses when to call memory functions), enable auto function calling — see “Auto function calling” below.
Core concepts
SynapPlugin
SynapPlugin is a regular Semantic Kernel plugin class with @kernel_function annotated methods. Adding it to the kernel registers both functions under the plugin name you choose:
synap.search_memory and synap.store_memory either through prompt templating, manual invocation, or auto function calling.
search_memory
Function signature exposed to the kernel:store_memory
Function signature exposed to the kernel:"Memory stored successfully." on success. Store failures surface explicitly — the function raises SynapIntegrationError so the kernel (and caller) know if persistence failed.
Complete example: chat function with auto-invoked memory
The following kernel auto-invokessynap.search_memory and synap.store_memory whenever the model decides they are relevant. The application just adds messages to a ChatHistory and the kernel handles the rest:
FunctionChoiceBehavior.Auto()lets the model drive memory. No prompt-template plumbing — the model calls the right function when it’s the right time.- Scope is per-kernel.
build_kernel(...)constructs a fresh kernel per user so concurrent requests cannot bleed scope. - The system message is the policy. Tell the model when to search and when to store; the plugin just enforces it.
Advanced patterns
Multi-tenant scoping
SynapPlugin 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.
Prompt-template invocation
Outside of auto function calling, you can interpolate plugin calls directly in prompt templates:Failure semantics
The integration follows the Synap-wide contract:search_memorydegrades gracefully — returns an empty result string and logs an error if Synap is unreachable.store_memorysurfaces failures — raisesSynapIntegrationErrorso the kernel and caller know persistence failed.
Next steps
Microsoft Agent Framework
Context and history providers for MAF agents.
OpenAI Agents
Function tools for the OpenAI Agents SDK.
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.