Skip to main content

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 single system-role ChatMessage to the ChatContext so 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, ...) — wires AgentSession.on("conversation_item_added", ...) to sdk.conversation.record_message(). Handles both user and assistant turns (dispatched on item.role). Returns the conversation_id used 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 return FunctionTool instances registerable via Agent(tools=[...]). The LLM can invoke synap_search(query) to retrieve formatted context, or synap_store(content, category) to write a new memory.

Error policy

  • Reads (preload_synap_context, synap_search_tool) degrade gracefully. SDK failures log at ERROR, return an empty / "no relevant memory" placeholder, and the call proceeds.
  • Writes (attach_synap_recording, synap_store_tool) surface SynapIntegrationError via wrap_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 the SynapIntegrationError propagate to the LLM runtime so the model sees a tool failure.

Constructor args

All helpers accept:

  • sdk: a configured MaximemSynapSDK
  • user_id: required — Synap memory is user-scoped
  • customer_id: optional customer/org scope; empty string means customer-less
  • conversation_id (recording only): optional explicit id; auto-generated when absent
  • mode (read helpers only): "accurate" or "fast", passed through to sdk.fetch
  • max_results (read helpers only): cap per fetch

Release files for maximem-synap-livekit-agents 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for maximem-synap-livekit-agents 0.2.0
File Size Uploaded
maximem_synap_livekit_agents-0.2.0.tar.gz 10.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for maximem-synap-livekit-agents 0.2.0
File Interpreter ABI Platform
maximem_synap_livekit_agents-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.2 kB

Release files / maximem_synap_livekit_agents-0.2.0.tar.gz

Download URL maximem_synap_livekit_agents-0.2.0.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ece9df955cfc7cad900dcc4ef382289ab890bc71ae00c8a8aaaaec7893986624
BLAKE2b-256 checksum
How to use checksums
7607408f4b1fce1279efc575b9be0f3205ab825e05e79fc9d166938f31c56502
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / maximem_synap_livekit_agents-0.2.0-py3-none-any.whl

Download URL maximem_synap_livekit_agents-0.2.0-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7c089824c93cc0e244c0fb25ad95c81dbe8fae01db2452b663bd3e911491ea58
BLAKE2b-256 checksum
How to use checksums
7330c766b7d6632f95f159248e7499891646fe3f2ea3d5198d6cd27033d33c95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page