Python: samples: add Synap context provider example#5620
Python: samples: add Synap context provider example#5620visy-ani wants to merge 5 commits intomicrosoft:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new Python sample under the context provider samples to demonstrate integrating SynapContextProvider as a managed long-term memory source for Agent Framework agents.
Changes:
- Adds
synap_basic.pyto show wiring a Synap SDK instance and context provider into an agent flow. - Adds a sample README with setup, run steps, and external Synap documentation links.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
python/samples/02-agents/context_providers/synap/synap_basic.py |
New sample script intended to demonstrate Synap-backed context injection and memory recall across runs. |
python/samples/02-agents/context_providers/synap/README.md |
New documentation describing the sample, setup steps, execution command, and related resources. |
| async with Agent( | ||
| name="MemoryAssistant", | ||
| instructions="You are a helpful assistant with long-term memory.", | ||
| context_providers=[provider], | ||
| ) as agent: |
| provider = SynapContextProvider( | ||
| sdk=sdk, | ||
| user_id=user_id, | ||
| customer_id="acme_corp", | ||
| ) |
| ## Run | ||
|
|
||
| ```bash | ||
| python synap_basic.py |
|
@microsoft-github-policy-service agree [company="Maximem"] |
|
@microsoft-github-policy-service agree company=Maximem |
…recall, README setup docs
|
Hi @moonbox3 and @eavanvalkenburg — would appreciate a review when you get a chance! This adds a Copilot-flagged issues are now resolved: replaced the random |
|
@visy-ani normally we prefer for this type of integration to live in a separate repo, and we can link from our docs |
|
Got it, thanks @sphenry . The code already lives in our repo and is published as maximem-synap-microsoft-agent on PyPI. I'd be happy to convert this PR into a docs-only change that just links to it from your community integrations page , would that work? Just point me at the right file and I'll update the PR. |
Adds a sample demonstrating
SynapContextProvider— a Microsoft Agent FrameworkContextProviderbacked by Synap, a managed memory layer for AI agents.What's included
python/samples/02-agents/context_providers/synap/synap_basic.py— basic usage showing context injection and turn recordingpython/samples/02-agents/context_providers/synap/README.md— setup and run instructionsHow SynapContextProvider works
before_run: fetches Synap context relevant to the user's input and appends it to the agent's instructions viacontext.extend_instructions(...)after_run: records input and response messages to Synap viasdk.conversation.record_message(...)for future retrievalRead failures degrade gracefully (log + skip). Write failures are logged but never re-raised — the agent run always completes. This matches the contract established by
Mem0ContextProvider.Memory is scoped to
user_idandcustomer_id, ensuring strict isolation in multi-tenant applications.Install:
pip install maximem-synap-microsoft-agentPyPI: https://pypi.org/project/maximem-synap-microsoft-agent/
Docs: https://docs.maximem.ai/integrations/microsoft-agent
Open source: Integration package source at
maximem-ai/maximem_synap_sdk— contributions welcome