examples: add Synap persistent memory integration#5636
examples: add Synap persistent memory integration#5636visy-ani wants to merge 6 commits intolivekit:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new example intended to show how a LiveKit voice agent can integrate Synap for persistent cross-session memory, fitting into the repositoryβs example suite for third-party integrations.
Changes:
- Adds
examples/other/synap_memory.pyas a standalone Synap integration example. - Demonstrates preloading long-term memory, automatic conversation recording, and LLM-callable memory tools.
- Wires the example to a LiveKit
AgentSessionusing OpenAI and Synap SDK/tool helpers.
π‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| USER_ID = "demo-user-001" | ||
| CUSTOMER_ID = "demo-customer" |
| session = AgentSession( | ||
| llm=openai.LLM(model="gpt-4o"), | ||
| chat_ctx=chat_ctx, | ||
| ) |
| session = AgentSession( | ||
| llm=openai.LLM(model="gpt-4o"), | ||
| chat_ctx=chat_ctx, | ||
| ) | ||
|
|
||
| # 2. Automatically record every user transcription and assistant response | ||
| attach_synap_recording(session, sdk, user_id=USER_ID, customer_id=CUSTOMER_ID) | ||
|
|
||
| await session.start( | ||
| agent=agent, | ||
| room=ctx.room, | ||
| room_input_options=RoomInputOptions(), |
| synap_store_tool, | ||
| ) | ||
|
|
||
| sdk = MaximemSynapSDK(api_key=os.environ["SYNAP_API_KEY"]) |
| Get an API key at synap.maximem.ai | ||
| """ | ||
|
|
||
| import asyncio |
| await session.start( | ||
| agent=agent, | ||
| room=ctx.room, | ||
| room_input_options=RoomInputOptions(), |
| Demonstrates three patterns for giving a LiveKit voice agent persistent, | ||
| cross-session memory via Synap (https://maximem.ai): | ||
|
|
||
| 1. preload_synap_context β inject long-term memory before the call starts | ||
| 2. attach_synap_recording β record every turn automatically | ||
| 3. synap_search_tool β LLM-callable tool for explicit memory search |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
π‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| await session.start( | ||
| agent=agent, | ||
| room=ctx.room, | ||
| room_input_options=RoomInputOptions(), |
|
|
||
| 1. preload_synap_context β inject long-term memory before the call starts | ||
| 2. attach_synap_recording β record every turn automatically | ||
| 3. synap_search_tool β LLM-callable tool for explicit memory search |
|
Hi @theomonnom and @chenghao-mou β would love to get a review on this when you get a chance! This adds a Synap persistent memory example to All bot-flagged issues have been resolved (Devin's 3 red bugs, Copilot's unused import, missing |
|
Hi @theomonnom and @chenghao-mou π β friendly follow-up here whenever you have a chance. All CI is green and the example is ready for review. No rush β just flagging it in case it slipped past. Thanks! |
Adds
examples/other/synap_memory.pyβ a complete example showing how to give a LiveKit voice agent persistent, cross-session memory via Synap.What's demonstrated
Three integration patterns in one file:
preload_synap_contextβ injects the user's long-term memory as a system message intoChatContextbefore the session starts, so the LLM sees it on its first turnattach_synap_recordingβ wires aconversation_item_addedlistener that records every user transcription and assistant response to Synap automaticallysynap_search_toolandsynap_store_toolfactory functions that returnFunctionToolinstances for explicit agent-driven memory accessError policy
Install:
pip install maximem-synap-livekit-agentsPyPI: https://pypi.org/project/maximem-synap-livekit-agents/
Docs: https://docs.maximem.ai/integrations/livekit-agents
Open source: Integration package source at
maximem-ai/maximem_synap_sdkβ contributions welcome