Synap memory integration for LiveKit Agents — preload long-term memory, record turns, expose Synap as LLM tools
Project description
synap-livekit-agents
Synap integration for LiveKit Agents — preload long-term memory before a realtime call, record every committed turn back to Synap, and expose Synap search/store as LLM-callable function tools.
Install
pip install synap-livekit-agents
Requires livekit-agents>=1.0, maximem-synap>=0.2.0.
Quickstart
from livekit.agents import Agent, AgentSession, ChatContext
from maximem_synap import MaximemSynapSDK
from synap_livekit_agents import (
preload_synap_context,
attach_synap_recording,
synap_search_tool,
synap_store_tool,
)
sdk = MaximemSynapSDK(api_key="sk-...")
async def entrypoint(ctx):
chat_ctx = ChatContext()
await preload_synap_context(
chat_ctx, sdk, user_id="alice", customer_id="acme",
)
agent = Agent(
instructions="You are a helpful assistant.",
chat_ctx=chat_ctx,
tools=[
synap_search_tool(sdk, user_id="alice", customer_id="acme"),
synap_store_tool(sdk, user_id="alice", customer_id="acme"),
],
)
session = AgentSession(...)
conversation_id = attach_synap_recording(
session, sdk, user_id="alice", customer_id="acme",
)
await session.start(agent=agent, room=ctx.room)
Scope
preload_synap_context(chat_ctx, sdk, *, user_id, ...)— async helper. Fetches user-scoped context from Synap and prepends a singlesystem-roleChatMessageto theChatContextso the agent starts with long-term memory in scope. Read failures degrade silently — a Synap blip must never prevent a call from starting.attach_synap_recording(session, sdk, *, user_id, ...)— wiresAgentSession.on("conversation_item_added", ...)tosdk.conversation.record_message(). Handles both user and assistant turns (dispatched onitem.role). Returns theconversation_idused for this call (auto-generated per call when absent). Callbacks never raise — write failures are logged and swallowed, consistent with LiveKit's sync-event contract.synap_search_tool(sdk, *, user_id, ...)/synap_store_tool(sdk, *, user_id, ...)— factories that returnFunctionToolinstances registerable viaAgent(tools=[...]). The LLM can invokesynap_search(query)to retrieve formatted context, orsynap_store(content, category)to write a new memory.
Error policy
- Reads (
preload_synap_context,synap_search_tool) degrade gracefully. SDK failures log atERROR, return an empty / "no relevant memory" placeholder, and the call proceeds. - Writes (
attach_synap_recording,synap_store_tool) surfaceSynapIntegrationErrorviawrap_sdk_errors_async. The recording callback catches+logs (can't bubble an exception out of a sync LiveKit event emission without tearing down the session); the store tool lets theSynapIntegrationErrorpropagate to the LLM runtime so the model sees a tool failure.
Constructor args
All helpers accept:
sdk: a configuredMaximemSynapSDKuser_id: required — Synap memory is user-scopedcustomer_id: optional customer/org scope; empty string means customer-lessconversation_id(recording only): optional explicit id; auto-generated when absentmode(read helpers only):"accurate"or"fast", passed through tosdk.fetchmax_results(read helpers only): cap per fetch
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file maximem_synap_livekit_agents-0.1.3.tar.gz.
File metadata
- Download URL: maximem_synap_livekit_agents-0.1.3.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abb34ad840a575ac4f9d9fb65a43d8834a1246b3c86f1ac4d2d5bf0ef6d304e6
|
|
| MD5 |
aca6d6f21815a17f718d000e7b33356f
|
|
| BLAKE2b-256 |
e112346244d9ab3ca1677e62efb981deb8636dcb4c6b8c3e4493d07ee5f582a0
|
File details
Details for the file maximem_synap_livekit_agents-0.1.3-py3-none-any.whl.
File metadata
- Download URL: maximem_synap_livekit_agents-0.1.3-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9aee2de589d570501d759e5284c094e01448973b04283dc8d6b7433b3e7fe77f
|
|
| MD5 |
42ccbe54a0ba2cf00fb1d79c0b61c20f
|
|
| BLAKE2b-256 |
90f0c0f0cbc365d06fe146987cda0a2259684f56d3dcd51b90c72c3f6fd7d5c1
|