livekit-memorysync 1.0.0__tar.gz → 1.1.0__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.
- {livekit_memorysync-1.0.0 → livekit_memorysync-1.1.0}/.gitignore +5 -5
- {livekit_memorysync-1.0.0 → livekit_memorysync-1.1.0}/PKG-INFO +22 -15
- {livekit_memorysync-1.0.0 → livekit_memorysync-1.1.0}/README.md +125 -118
- {livekit_memorysync-1.0.0 → livekit_memorysync-1.1.0}/pyproject.toml +42 -42
- {livekit_memorysync-1.0.0 → livekit_memorysync-1.1.0}/src/livekit_memorysync/__init__.py +41 -40
- {livekit_memorysync-1.0.0 → livekit_memorysync-1.1.0}/src/livekit_memorysync/_api.py +309 -295
- {livekit_memorysync-1.0.0 → livekit_memorysync-1.1.0}/src/livekit_memorysync/_version.py +3 -3
- {livekit_memorysync-1.0.0 → livekit_memorysync-1.1.0}/src/livekit_memorysync/agent.py +77 -76
- {livekit_memorysync-1.0.0 → livekit_memorysync-1.1.0}/src/livekit_memorysync/memory.py +332 -322
- {livekit_memorysync-1.0.0 → livekit_memorysync-1.1.0}/src/livekit_memorysync/tools.py +38 -38
- livekit_memorysync-1.1.0/tests/conftest.py +258 -0
- {livekit_memorysync-1.0.0 → livekit_memorysync-1.1.0}/tests/test_memory.py +365 -340
- livekit_memorysync-1.0.0/tests/conftest.py +0 -169
|
@@ -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.
|
|
4
|
-
Summary: MemorySync for LiveKit Agents: voice agents that remember callers — budgeted recall injection (never a stalled reply),
|
|
3
|
+
Version: 1.1.0
|
|
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/
|
|
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
|
-
- **
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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(
|
|
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) #
|
|
78
|
+
memory.attach(session) # send the caller's turns as they finalize
|
|
76
79
|
await session.start(agent=Assistant(), ...)
|
|
77
80
|
```
|
|
78
81
|
|
|
@@ -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
|
|
127
|
-
never re-
|
|
128
|
-
-
|
|
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
|
-
|
|
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 #
|
|
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
|
-
- **
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
- **
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
memory.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
|
86
|
-
|
|
|
87
|
-
| `
|
|
88
|
-
| `
|
|
89
|
-
| `
|
|
90
|
-
| `
|
|
91
|
-
| `
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
##
|
|
117
|
-
|
|
118
|
-
|
|
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` | `None` | Scope memories to one room/call thread |
|
|
91
|
+
| `recall_timeout` | `1.2` | Hard budget (seconds) for recall injection |
|
|
92
|
+
| `top_k` | `5` | 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),
|
|
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/
|
|
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) #
|
|
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 **
|
|
20
|
-
(fire-and-forget with content-hash idempotency seeds
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
from .
|
|
27
|
-
from .
|
|
28
|
-
from .
|
|
29
|
-
from .
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
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
|
+
]
|