Skip to content

examples: add Synap persistent memory integration#5636

Open
visy-ani wants to merge 6 commits intolivekit:mainfrom
visy-ani:add-synap-memory-example
Open

examples: add Synap persistent memory integration#5636
visy-ani wants to merge 6 commits intolivekit:mainfrom
visy-ani:add-synap-memory-example

Conversation

@visy-ani
Copy link
Copy Markdown

@visy-ani visy-ani commented May 4, 2026

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:

  1. preload_synap_context β€” injects the user's long-term memory as a system message into ChatContext before the session starts, so the LLM sees it on its first turn
  2. attach_synap_recording β€” wires a conversation_item_added listener that records every user transcription and assistant response to Synap automatically
  3. LLM-callable tools β€” synap_search_tool and synap_store_tool factory functions that return FunctionTool instances for explicit agent-driven memory access

Error policy

  • Read failures (preload, search) degrade silently β€” a Synap outage never prevents a call from starting or a tool call from returning
  • Write failures (recording, store) are logged at ERROR but swallowed β€” a Synap write blip never tears down a live call

Install: pip install maximem-synap-livekit-agents
PyPI: 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

Copilot AI review requested due to automatic review settings May 4, 2026 09:08
devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py as a standalone Synap integration example.
  • Demonstrates preloading long-term memory, automatic conversation recording, and LLM-callable memory tools.
  • Wires the example to a LiveKit AgentSession using OpenAI and Synap SDK/tool helpers.

πŸ’‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +30 to +31
USER_ID = "demo-user-001"
CUSTOMER_ID = "demo-customer"
Comment on lines +57 to +60
session = AgentSession(
llm=openai.LLM(model="gpt-4o"),
chat_ctx=chat_ctx,
)
Comment thread examples/other/synap_memory.py Outdated
Comment on lines +57 to +68
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"])
Comment thread examples/other/synap_memory.py Outdated
Get an API key at synap.maximem.ai
"""

import asyncio
Comment thread examples/other/synap_memory.py Outdated
await session.start(
agent=agent,
room=ctx.room,
room_input_options=RoomInputOptions(),
Comment thread examples/other/synap_memory.py Outdated
Comment on lines +3 to +8
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
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 4, 2026

CLA assistant check
All committers have signed the CLA.

devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread examples/other/synap_memory.py Outdated
Comment on lines +72 to +75
await session.start(
agent=agent,
room=ctx.room,
room_input_options=RoomInputOptions(),
Comment thread examples/other/synap_memory.py Outdated

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
devin-ai-integration[bot]

This comment was marked as resolved.

@visy-ani
Copy link
Copy Markdown
Author

visy-ani commented May 4, 2026

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 examples/other/.

All bot-flagged issues have been resolved (Devin's 3 red bugs, Copilot's unused import, missing load_dotenv, deprecated RoomInputOptions, and ctx: JobContext type annotation). Happy to make any further changes you'd like. Thanks!

@visy-ani
Copy link
Copy Markdown
Author

visy-ani commented May 7, 2026

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants