livekit-memorysync 1.0.0__tar.gz → 1.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- venv/
2
- __pycache__/
3
- .pytest_cache/
4
- dist/
5
- *.egg-info/
1
+ venv/
2
+ __pycache__/
3
+ .pytest_cache/
4
+ dist/
5
+ *.egg-info/
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: livekit-memorysync
3
- Version: 1.0.0
4
- Summary: MemorySync for LiveKit Agents: voice agents that remember callers — budgeted recall injection (never a stalled reply), both-role capture with idempotency seeds, and background prefetch.
3
+ Version: 1.1.1
4
+ Summary: MemorySync for LiveKit Agents: voice agents that remember callers — budgeted recall injection (never a stalled reply), fact capture from the caller's turns with idempotency seeds, and background prefetch.
5
5
  Project-URL: Homepage, https://docs.memorysync.io/guides/livekit
6
6
  Project-URL: Documentation, https://docs.memorysync.io/guides/livekit
7
- Project-URL: Repository, https://github.com/Rafay121/memorysync-plugins
7
+ Project-URL: Repository, https://github.com/memorysyncio/memorysync-plugins
8
8
  Author-email: MemorySync <support@memorysync.io>
9
9
  License-Expression: MIT
10
10
  Keywords: agents,livekit,long-term-memory,memory,memorysync,voice
@@ -41,11 +41,14 @@ This package is built around that constraint:
41
41
  time, the reply proceeds *without* memories — never late.
42
42
  - **Background prefetch.** After each turn, the next recall is warmed in the
43
43
  background, so the common case is an instant cache hit, not a network call.
44
- - **Both-role capture.** User *and* assistant turns are persisted (with
45
- interruption metadata) via `conversation_item_added` — competitors that only
46
- store user turns lose half the conversation.
47
- - **Delta-only, idempotent writes.** Every stored turn carries a deterministic
48
- seed, so retries and reconnects never duplicate memories.
44
+ - **Fact capture from the caller.** Each of the caller's turns is sent to fact
45
+ extraction as it finalizes (`conversation_item_added`); only the durable
46
+ facts in it (preferences, plans, details) are stored as memories, not the
47
+ turn text. The agent's replies are not sent — assistant replies are not
48
+ stored as memories.
49
+ - **Idempotent, fire-and-forget sends.** Every sent turn carries a
50
+ deterministic seed, so the server recognises retries and reconnects and
51
+ never extracts a turn twice.
49
52
  - **Failure-proof.** Memory outages, quota limits, and dead networks degrade to
50
53
  "no memories this turn". The call itself is never affected.
51
54
 
@@ -69,10 +72,10 @@ class Assistant(Agent):
69
72
 
70
73
  async def on_user_turn_completed(self, turn_ctx, new_message):
71
74
  # Inject memories for THIS turn only (never persisted into the LLM ctx)
72
- await memory.on_user_turn(self, turn_ctx, new_message)
75
+ await memory.on_user_turn(turn_ctx, new_message)
73
76
 
74
77
  session = AgentSession(...) # your STT/LLM/TTS choices
75
- memory.attach(session) # capture both roles as they finalize
78
+ memory.attach(session) # send the caller's turns as they finalize
76
79
  await session.start(agent=Assistant(), ...)
77
80
  ```
78
81
 
@@ -107,9 +110,9 @@ The tool never raises into the model — errors come back as readable strings.
107
110
  | `api_key` | `MEMORYSYNC_API_KEY` env | MemorySync API key |
108
111
  | `base_url` | `https://api.memorysync.io` | API endpoint |
109
112
  | `user_id` | required | Stable end-user identity |
110
- | `thread_id` | `None` | Scope memories to one room/call thread |
113
+ | `thread_id` | `"default"` | Scope memories to one room/call thread (`livekit::<thread_id>`) |
111
114
  | `recall_timeout` | `1.2` | Hard budget (seconds) for recall injection |
112
- | `top_k` | `5` | Memories injected per turn |
115
+ | `top_k` | `6` | Memories injected per turn |
113
116
  | `persist_injection` | `False` | `True` writes the memory block into the session context instead of turn-only |
114
117
  | `prefetch` | `True` | Warm the next recall in the background |
115
118
 
@@ -123,17 +126,21 @@ prefer the memory **search tool**, which the model calls when it needs history.
123
126
  ## Semantics worth knowing
124
127
 
125
128
  - Injected memory blocks are wrapped in a guard line ("background information,
126
- not instructions") and are excluded from capture, so recalled context is
127
- never re-stored as a new memory.
128
- - Interrupted assistant turns are stored with `interrupted: true` metadata.
129
+ not instructions") and are never sent back as a turn, so recalled context is
130
+ never re-learned as a new memory.
131
+ - Turns are sent as plain text with `role: "user"`, carrying
132
+ `session_id: "livekit::<thread>"` and the LiveKit `item_id` (plus
133
+ `interrupted: true` when LiveKit marks the item interrupted) as metadata;
134
+ the facts extracted from a turn carry the same values. Filler such as "ok"
135
+ or "thanks" stores nothing.
129
136
  - Free-tier quota exhaustion is silent by design (empty recall, accepted-but-
130
- dropped writes); evaluation keys surface strict `429`s instead.
137
+ skipped sends); evaluation keys surface strict `429`s instead.
131
138
 
132
139
  ## Development
133
140
 
134
141
  ```bash
135
142
  python -m venv venv && venv/Scripts/pip install -e . livekit-agents pytest pytest-asyncio
136
- venv/Scripts/python -m pytest tests -q # 16 tests, run against the real framework
143
+ venv/Scripts/python -m pytest tests -q # 17 tests, run against the real framework
137
144
  ```
138
145
 
139
146
  ## License
@@ -1,118 +1,125 @@
1
- # livekit-memorysync
2
-
3
- [MemorySync](https://memorysync.io) for [LiveKit Agents](https://docs.livekit.io/agents/) —
4
- voice agents that remember callers across calls, without ever stalling a reply.
5
-
6
- ```bash
7
- pip install livekit-memorysync
8
- ```
9
-
10
- ## Why this exists
11
-
12
- Voice is the one surface where memory latency is *audible*. A text chatbot can
13
- spend two seconds fetching context; a voice agent that does so sounds broken.
14
- This package is built around that constraint:
15
-
16
- - **Budgeted recall.** Memory context is injected in `on_user_turn_completed`
17
- under a hard timeout (default **1.2 s**). If MemorySync doesn't answer in
18
- time, the reply proceeds *without* memories — never late.
19
- - **Background prefetch.** After each turn, the next recall is warmed in the
20
- background, so the common case is an instant cache hit, not a network call.
21
- - **Both-role capture.** User *and* assistant turns are persisted (with
22
- interruption metadata) via `conversation_item_added` — competitors that only
23
- store user turns lose half the conversation.
24
- - **Delta-only, idempotent writes.** Every stored turn carries a deterministic
25
- seed, so retries and reconnects never duplicate memories.
26
- - **Failure-proof.** Memory outages, quota limits, and dead networks degrade to
27
- "no memories this turn". The call itself is never affected.
28
-
29
- ## Quick start (composition — recommended)
30
-
31
- Keep your own `Agent` subclass; attach memory to it:
32
-
33
- ```python
34
- from livekit.agents import Agent, AgentSession
35
- from livekit_memorysync import MemorySyncMemory
36
-
37
- memory = MemorySyncMemory(
38
- api_key="ms_...", # or MEMORYSYNC_API_KEY env var
39
- user_id="caller-42", # stable end-user id
40
- thread_id="room-123", # optional: scope to this room/call
41
- )
42
-
43
- class Assistant(Agent):
44
- def __init__(self) -> None:
45
- super().__init__(instructions="You are a helpful voice assistant.")
46
-
47
- async def on_user_turn_completed(self, turn_ctx, new_message):
48
- # Inject memories for THIS turn only (never persisted into the LLM ctx)
49
- await memory.on_user_turn(self, turn_ctx, new_message)
50
-
51
- session = AgentSession(...) # your STT/LLM/TTS choices
52
- memory.attach(session) # capture both roles as they finalize
53
- await session.start(agent=Assistant(), ...)
54
- ```
55
-
56
- ## Quick start (drop-in agent)
57
-
58
- ```python
59
- from livekit_memorysync import MemorySyncAgent
60
-
61
- agent = MemorySyncAgent(
62
- instructions="You are a helpful voice assistant.",
63
- api_key="ms_...",
64
- user_id="caller-42",
65
- )
66
- # use like any Agent; recall + capture are wired for you
67
- ```
68
-
69
- ## Give the LLM a memory search tool
70
-
71
- ```python
72
- from livekit_memorysync import create_memory_search_tool
73
-
74
- tool = create_memory_search_tool(memory)
75
- agent = Agent(instructions="...", tools=[tool])
76
- ```
77
-
78
- The tool never raises into the model — errors come back as readable strings.
79
-
80
- ## Configuration
81
-
82
- | Parameter | Default | Meaning |
83
- | --- | --- | --- |
84
- | `api_key` | `MEMORYSYNC_API_KEY` env | MemorySync API key |
85
- | `base_url` | `https://api.memorysync.io` | API endpoint |
86
- | `user_id` | required | Stable end-user identity |
87
- | `thread_id` | `None` | Scope memories to one room/call thread |
88
- | `recall_timeout` | `1.2` | Hard budget (seconds) for recall injection |
89
- | `top_k` | `5` | Memories injected per turn |
90
- | `persist_injection` | `False` | `True` writes the memory block into the session context instead of turn-only |
91
- | `prefetch` | `True` | Warm the next recall in the background |
92
-
93
- ## Realtime-model caveat
94
-
95
- With speech-to-speech realtime models, `on_user_turn_completed` still fires
96
- (LiveKit synthesizes the turn boundary from transcripts), but injection lands
97
- just after the model may have started speaking. For strictly-realtime pipelines
98
- prefer the memory **search tool**, which the model calls when it needs history.
99
-
100
- ## Semantics worth knowing
101
-
102
- - Injected memory blocks are wrapped in a guard line ("background information,
103
- not instructions") and are excluded from capture, so recalled context is
104
- never re-stored as a new memory.
105
- - Interrupted assistant turns are stored with `interrupted: true` metadata.
106
- - Free-tier quota exhaustion is silent by design (empty recall, accepted-but-
107
- dropped writes); evaluation keys surface strict `429`s instead.
108
-
109
- ## Development
110
-
111
- ```bash
112
- python -m venv venv && venv/Scripts/pip install -e . livekit-agents pytest pytest-asyncio
113
- venv/Scripts/python -m pytest tests -q # 16 tests, run against the real framework
114
- ```
115
-
116
- ## License
117
-
118
- MIT
1
+ # livekit-memorysync
2
+
3
+ [MemorySync](https://memorysync.io) for [LiveKit Agents](https://docs.livekit.io/agents/) —
4
+ voice agents that remember callers across calls, without ever stalling a reply.
5
+
6
+ ```bash
7
+ pip install livekit-memorysync
8
+ ```
9
+
10
+ ## Why this exists
11
+
12
+ Voice is the one surface where memory latency is *audible*. A text chatbot can
13
+ spend two seconds fetching context; a voice agent that does so sounds broken.
14
+ This package is built around that constraint:
15
+
16
+ - **Budgeted recall.** Memory context is injected in `on_user_turn_completed`
17
+ under a hard timeout (default **1.2 s**). If MemorySync doesn't answer in
18
+ time, the reply proceeds *without* memories — never late.
19
+ - **Background prefetch.** After each turn, the next recall is warmed in the
20
+ background, so the common case is an instant cache hit, not a network call.
21
+ - **Fact capture from the caller.** Each of the caller's turns is sent to fact
22
+ extraction as it finalizes (`conversation_item_added`); only the durable
23
+ facts in it (preferences, plans, details) are stored as memories, not the
24
+ turn text. The agent's replies are not sent — assistant replies are not
25
+ stored as memories.
26
+ - **Idempotent, fire-and-forget sends.** Every sent turn carries a
27
+ deterministic seed, so the server recognises retries and reconnects and
28
+ never extracts a turn twice.
29
+ - **Failure-proof.** Memory outages, quota limits, and dead networks degrade to
30
+ "no memories this turn". The call itself is never affected.
31
+
32
+ ## Quick start (composition — recommended)
33
+
34
+ Keep your own `Agent` subclass; attach memory to it:
35
+
36
+ ```python
37
+ from livekit.agents import Agent, AgentSession
38
+ from livekit_memorysync import MemorySyncMemory
39
+
40
+ memory = MemorySyncMemory(
41
+ api_key="ms_...", # or MEMORYSYNC_API_KEY env var
42
+ user_id="caller-42", # stable end-user id
43
+ thread_id="room-123", # optional: scope to this room/call
44
+ )
45
+
46
+ class Assistant(Agent):
47
+ def __init__(self) -> None:
48
+ super().__init__(instructions="You are a helpful voice assistant.")
49
+
50
+ async def on_user_turn_completed(self, turn_ctx, new_message):
51
+ # Inject memories for THIS turn only (never persisted into the LLM ctx)
52
+ await memory.on_user_turn(turn_ctx, new_message)
53
+
54
+ session = AgentSession(...) # your STT/LLM/TTS choices
55
+ memory.attach(session) # send the caller's turns as they finalize
56
+ await session.start(agent=Assistant(), ...)
57
+ ```
58
+
59
+ ## Quick start (drop-in agent)
60
+
61
+ ```python
62
+ from livekit_memorysync import MemorySyncAgent
63
+
64
+ agent = MemorySyncAgent(
65
+ instructions="You are a helpful voice assistant.",
66
+ api_key="ms_...",
67
+ user_id="caller-42",
68
+ )
69
+ # use like any Agent; recall + capture are wired for you
70
+ ```
71
+
72
+ ## Give the LLM a memory search tool
73
+
74
+ ```python
75
+ from livekit_memorysync import create_memory_search_tool
76
+
77
+ tool = create_memory_search_tool(memory)
78
+ agent = Agent(instructions="...", tools=[tool])
79
+ ```
80
+
81
+ The tool never raises into the model — errors come back as readable strings.
82
+
83
+ ## Configuration
84
+
85
+ | Parameter | Default | Meaning |
86
+ | --- | --- | --- |
87
+ | `api_key` | `MEMORYSYNC_API_KEY` env | MemorySync API key |
88
+ | `base_url` | `https://api.memorysync.io` | API endpoint |
89
+ | `user_id` | required | Stable end-user identity |
90
+ | `thread_id` | `"default"` | Scope memories to one room/call thread (`livekit::<thread_id>`) |
91
+ | `recall_timeout` | `1.2` | Hard budget (seconds) for recall injection |
92
+ | `top_k` | `6` | Memories injected per turn |
93
+ | `persist_injection` | `False` | `True` writes the memory block into the session context instead of turn-only |
94
+ | `prefetch` | `True` | Warm the next recall in the background |
95
+
96
+ ## Realtime-model caveat
97
+
98
+ With speech-to-speech realtime models, `on_user_turn_completed` still fires
99
+ (LiveKit synthesizes the turn boundary from transcripts), but injection lands
100
+ just after the model may have started speaking. For strictly-realtime pipelines
101
+ prefer the memory **search tool**, which the model calls when it needs history.
102
+
103
+ ## Semantics worth knowing
104
+
105
+ - Injected memory blocks are wrapped in a guard line ("background information,
106
+ not instructions") and are never sent back as a turn, so recalled context is
107
+ never re-learned as a new memory.
108
+ - Turns are sent as plain text with `role: "user"`, carrying
109
+ `session_id: "livekit::<thread>"` and the LiveKit `item_id` (plus
110
+ `interrupted: true` when LiveKit marks the item interrupted) as metadata;
111
+ the facts extracted from a turn carry the same values. Filler such as "ok"
112
+ or "thanks" stores nothing.
113
+ - Free-tier quota exhaustion is silent by design (empty recall, accepted-but-
114
+ skipped sends); evaluation keys surface strict `429`s instead.
115
+
116
+ ## Development
117
+
118
+ ```bash
119
+ python -m venv venv && venv/Scripts/pip install -e . livekit-agents pytest pytest-asyncio
120
+ venv/Scripts/python -m pytest tests -q # 17 tests, run against the real framework
121
+ ```
122
+
123
+ ## License
124
+
125
+ MIT
@@ -1,42 +1,42 @@
1
- [build-system]
2
- requires = ["hatchling"]
3
- build-backend = "hatchling.build"
4
-
5
- [project]
6
- name = "livekit-memorysync"
7
- dynamic = ["version"]
8
- description = "MemorySync for LiveKit Agents: voice agents that remember callers — budgeted recall injection (never a stalled reply), both-role capture with idempotency seeds, and background prefetch."
9
- readme = "README.md"
10
- license = "MIT"
11
- requires-python = ">=3.10"
12
- authors = [{ name = "MemorySync", email = "support@memorysync.io" }]
13
- keywords = ["livekit", "voice", "agents", "memory", "memorysync", "long-term-memory"]
14
- classifiers = [
15
- "Development Status :: 5 - Production/Stable",
16
- "Intended Audience :: Developers",
17
- "Programming Language :: Python :: 3",
18
- "Programming Language :: Python :: 3.10",
19
- "Programming Language :: Python :: 3.11",
20
- "Programming Language :: Python :: 3.12",
21
- "Topic :: Communications :: Conferencing",
22
- "Topic :: Scientific/Engineering :: Artificial Intelligence",
23
- ]
24
- dependencies = [
25
- "livekit-agents>=1.0.0,<2",
26
- "httpx>=0.25,<1",
27
- ]
28
-
29
- [project.urls]
30
- Homepage = "https://docs.memorysync.io/guides/livekit"
31
- Documentation = "https://docs.memorysync.io/guides/livekit"
32
- Repository = "https://github.com/Rafay121/memorysync-plugins"
33
-
34
- [tool.hatch.version]
35
- path = "src/livekit_memorysync/_version.py"
36
-
37
- [tool.hatch.build.targets.wheel]
38
- packages = ["src/livekit_memorysync"]
39
-
40
- [tool.pytest.ini_options]
41
- asyncio_mode = "auto"
42
- testpaths = ["tests"]
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "livekit-memorysync"
7
+ dynamic = ["version"]
8
+ description = "MemorySync for LiveKit Agents: voice agents that remember callers — budgeted recall injection (never a stalled reply), fact capture from the caller's turns with idempotency seeds, and background prefetch."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.10"
12
+ authors = [{ name = "MemorySync", email = "support@memorysync.io" }]
13
+ keywords = ["livekit", "voice", "agents", "memory", "memorysync", "long-term-memory"]
14
+ classifiers = [
15
+ "Development Status :: 5 - Production/Stable",
16
+ "Intended Audience :: Developers",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.10",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Topic :: Communications :: Conferencing",
22
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
23
+ ]
24
+ dependencies = [
25
+ "livekit-agents>=1.0.0,<2",
26
+ "httpx>=0.25,<1",
27
+ ]
28
+
29
+ [project.urls]
30
+ Homepage = "https://docs.memorysync.io/guides/livekit"
31
+ Documentation = "https://docs.memorysync.io/guides/livekit"
32
+ Repository = "https://github.com/memorysyncio/memorysync-plugins"
33
+
34
+ [tool.hatch.version]
35
+ path = "src/livekit_memorysync/_version.py"
36
+
37
+ [tool.hatch.build.targets.wheel]
38
+ packages = ["src/livekit_memorysync"]
39
+
40
+ [tool.pytest.ini_options]
41
+ asyncio_mode = "auto"
42
+ testpaths = ["tests"]
@@ -1,40 +1,41 @@
1
- """MemorySync for LiveKit Agents — voice agents that remember callers.
2
-
3
- Two ways in, one engine:
4
-
5
- - **Composition (recommended)** — keep YOUR Agent subclass; wire two lines::
6
-
7
- memory = MemorySyncMemory(api_key=..., user_id="caller-123", thread_id=room_name)
8
-
9
- class MyAgent(Agent):
10
- async def on_user_turn_completed(self, turn_ctx, new_message):
11
- await memory.on_user_turn(turn_ctx, new_message)
12
-
13
- memory.attach(session) # captures BOTH sides of the conversation
14
-
15
- - **Drop-in** — ``MemorySyncAgent`` subclasses ``Agent`` and wires it for you.
16
-
17
- The voice contract this package is built around: **recall runs under a hard
18
- time budget** (default 1.2 s) — a slow network yields a memoryless turn,
19
- never a stalled spoken reply — and **persistence never blocks anything**
20
- (fire-and-forget with content-hash idempotency seeds, both roles captured,
21
- interruptions marked). A background prefetch primes the next turn's recall,
22
- so steady-state injection costs ~0 ms.
23
- """
24
-
25
- from ._api import AsyncV1Api, MemorySyncAPIError, fnv1a64
26
- from ._version import __version__
27
- from .memory import MemorySyncMemory, MemoryInjection
28
- from .agent import MemorySyncAgent
29
- from .tools import create_memory_search_tool
30
-
31
- __all__ = [
32
- "MemorySyncMemory",
33
- "MemorySyncAgent",
34
- "MemoryInjection",
35
- "create_memory_search_tool",
36
- "AsyncV1Api",
37
- "MemorySyncAPIError",
38
- "fnv1a64",
39
- "__version__",
40
- ]
1
+ """MemorySync for LiveKit Agents — voice agents that remember callers.
2
+
3
+ Two ways in, one engine:
4
+
5
+ - **Composition (recommended)** — keep YOUR Agent subclass; wire two lines::
6
+
7
+ memory = MemorySyncMemory(api_key=..., user_id="caller-123", thread_id=room_name)
8
+
9
+ class MyAgent(Agent):
10
+ async def on_user_turn_completed(self, turn_ctx, new_message):
11
+ await memory.on_user_turn(turn_ctx, new_message)
12
+
13
+ memory.attach(session) # sends the caller's turns to fact extraction
14
+
15
+ - **Drop-in** — ``MemorySyncAgent`` subclasses ``Agent`` and wires it for you.
16
+
17
+ The voice contract this package is built around: **recall runs under a hard
18
+ time budget** (default 1.2 s) — a slow network yields a memoryless turn,
19
+ never a stalled spoken reply — and **capture never blocks anything**
20
+ (fire-and-forget with content-hash idempotency seeds; only the caller's
21
+ turns are sent, and only the durable facts in them are stored — assistant
22
+ replies are not). A background prefetch primes the next turn's recall,
23
+ so steady-state injection costs ~0 ms.
24
+ """
25
+
26
+ from ._api import AsyncV1Api, MemorySyncAPIError, fnv1a64
27
+ from ._version import __version__
28
+ from .memory import MemorySyncMemory, MemoryInjection
29
+ from .agent import MemorySyncAgent
30
+ from .tools import create_memory_search_tool
31
+
32
+ __all__ = [
33
+ "MemorySyncMemory",
34
+ "MemorySyncAgent",
35
+ "MemoryInjection",
36
+ "create_memory_search_tool",
37
+ "AsyncV1Api",
38
+ "MemorySyncAPIError",
39
+ "fnv1a64",
40
+ "__version__",
41
+ ]