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, ...)— reports the whole turn, not just its two ends. Wires four listeners onto oneAgentSessionand returns theconversation_idused for this call (auto-generated when absent). Callbacks never raise — write failures are logged and swallowed, consistent with LiveKit's sync-event contract.LiveKit event Reported as conversation_item_addedthe user or assistant turn tool_execution_updated(ToolCallStarted)the tool call, at dispatch function_tools_executedthe tool result, and the call if the dispatch event never arrived closeend of the Synap session A tool call and its result share LiveKit's own
call_id, so the anticipation agent reads them as one exchange. On a voice call the tool call is reported the moment the tool is dispatched, not when the batch finishes: the gap between a caller's question and the answer is dead air, and that gap is the whole window anticipation has to work in. -
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.
Stream first, REST only as a fallback, never both
When sdk.instance.listen() is running, turns go out as user_message / assistant_message stream events and sdk.conversation.record_message is not called. The server persists those two event types from the stream itself, so doing both would store the turn twice and extract it twice. With no stream open, nothing changes: the integration behaves exactly as it did before, over REST.
Tool calls, tool results and reasoning are anticipation hints. The server does not persist them, so they have no REST fallback and are simply silent when no stream is open.
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: B2B instances only, where it is required. Not accepted on a B2C instance, which rejects it with HTTP 400.conversation_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
Metadata
Release files for maximem-synap-livekit-agents 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| maximem_synap_livekit_agents-0.2.1.tar.gz | 23.9 kB | Without provenance | Details for maximem_synap_livekit_agents-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| maximem_synap_livekit_agents-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for maximem_synap_livekit_agents-0.2.1-py3-none-any.whl |
Total release size: 40.0 kB
Release files / maximem_synap_livekit_agents-0.2.1.tar.gz
| Download URL | maximem_synap_livekit_agents-0.2.1.tar.gz |
|---|---|
| Size | 23.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
89a12ec4ad7d3039d168feb193b31273b4ee76a5a39171eca6d4a17cf0b9df06
|
|
BLAKE2b-256 checksum How to use checksums |
e1c3ea6b3de743e298c3a0c0545fa32879989730a464fe816d7b43badeee2c47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.16
|
Release files / maximem_synap_livekit_agents-0.2.1-py3-none-any.whl
| Download URL | maximem_synap_livekit_agents-0.2.1-py3-none-any.whl |
|---|---|
| Size | 16.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c85bc69999f65b2e9798d36bbc228ea8e4f7acfd762d40711c00a8e1294f07c1
|
|
BLAKE2b-256 checksum How to use checksums |
4af0395caa4655a45c19d73a3e6e25546f38aa136b2063e61196ed2573cbfe41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.16
|
Security for maximem-synap-livekit-agents 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.