livekit-memorysync 1.1.1__tar.gz → 1.2.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.
@@ -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/
@@ -0,0 +1,64 @@
1
+ # Changelog
2
+
3
+ All notable changes to `livekit-memorysync` are documented here. (Versions up
4
+ to 1.1.1 were published without a changelog.)
5
+
6
+ ## 1.2.0 — 2026-12-03
7
+
8
+ Sends the optional `context` field of `POST /v1/memory/add_turn`, which
9
+ the MemorySync API takes since 3 December 2026. A server that does not
10
+ know the field ignores it, and everything else works.
11
+
12
+ - **Changed: the header of the injected block** is "Additional information
13
+ relevant to the user's next message (via MemorySync): what the user said
14
+ before, and what their organization has stored:". Recall also returns the
15
+ organization's memories (its connectors' and the web crawler's), which the
16
+ old header ("recalled from previous conversations") presented as the
17
+ caller's own words. Code that matched on the old text should match on the
18
+ new one.
19
+ - **Changed: an empty `user_id` is refused.** `MemorySyncMemory(user_id="")`
20
+ (or `None`, or blanks) raises `ValueError` at construction, as the Pipecat
21
+ package always did; `MemorySyncAgent` refuses it the same way. It used to
22
+ be accepted, and the server then filed every such caller under ONE end
23
+ user, each of them given the others' facts. Code that relied on passing an
24
+ empty id must now pass the caller's own stable id.
25
+ - **Changed: what `prefetch` does.** Every turn now recalls for the CURRENT
26
+ utterance, under the `recall_timeout` budget. With `prefetch=True` (still
27
+ the default) the last block recalled is kept and is used only when the
28
+ recall for the current utterance is not back in time. Before, each turn
29
+ started a recall for its own words in the background and the NEXT turn was
30
+ given that block and made no recall of its own: a turn got the memories
31
+ that fitted the utterance before it. The price is that a turn waits for
32
+ its own recall (at most `recall_timeout`, 1.2 s by default) where it used
33
+ to inject at once; it also makes one recall a turn instead of two.
34
+ - **A caller's utterance reaches the server whole.** Consecutive user items
35
+ are one turn: each new one sends the run joined, never the new piece
36
+ alone. An item LiveKit marks `interrupted` is no longer sent as a turn of
37
+ its own: it is held and goes out joined with the caller's next item (the
38
+ joined turn keeps `interrupted: true` in its metadata). A cut sentence
39
+ that is never continued is not sent.
40
+ - **The agent's question goes along as context.** The assistant item before
41
+ a turn is sent in `context` (its end, 1,000 characters at most). It is
42
+ never sent as a turn; the server takes no fact from it and stores nothing
43
+ of it.
44
+ - **A failed send is tried again** (three times in all, after 0.5 s and
45
+ 2 s); a refusal another try cannot cure is sent once. Before, a send that
46
+ failed was lost: the event that brought the item does not come again.
47
+ - **The search tool has a time budget.** `create_memory_search_tool(memory,
48
+ timeout=...)`: default twice `recall_timeout`, at least 3 s. A slow server
49
+ now gets a sentence back to the model instead of silence on the call.
50
+ - **A refusal the developer can fix is said once, at warning level**:
51
+ `400 PROJECT_ID_REQUIRED` (the key has no project: pass `project_id=`),
52
+ and 401/403. Before, nothing was logged above debug level.
53
+ - `MemoryInjection.memory_count` counts memories, not the type headings of
54
+ the recall context. `top_k` is held to the 1..50 the recall route takes.
55
+ - `AsyncV1Api.add_turn` takes an optional `context`.
56
+ - Tests: 25. The fake server knows `context`, answers 403 on
57
+ `GET /org/projects` for a key without `projects:read` and
58
+ `400 PROJECT_ID_REQUIRED` for a key without a project when a test says
59
+ so, and refuses an empty `user_id`.
60
+
61
+ ## 1.1.1
62
+
63
+ Published before this changelog was kept: what changed up to this version is
64
+ not recorded here.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: livekit-memorysync
3
- Version: 1.1.1
3
+ Version: 1.2.0
4
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
@@ -39,8 +39,9 @@ This package is built around that constraint:
39
39
  - **Budgeted recall.** Memory context is injected in `on_user_turn_completed`
40
40
  under a hard timeout (default **1.2 s**). If MemorySync doesn't answer in
41
41
  time, the reply proceeds *without* memories — never late.
42
- - **Background prefetch.** After each turn, the next recall is warmed in the
43
- background, so the common case is an instant cache hit, not a network call.
42
+ - **The current utterance decides.** Every turn recalls for what the caller
43
+ just said. With `prefetch` on (the default) the last block recalled is kept
44
+ and fills in when that recall is not back within the budget.
44
45
  - **Fact capture from the caller.** Each of the caller's turns is sent to fact
45
46
  extraction as it finalizes (`conversation_item_added`); only the durable
46
47
  facts in it (preferences, plans, details) are stored as memories, not the
@@ -114,7 +115,21 @@ The tool never raises into the model — errors come back as readable strings.
114
115
  | `recall_timeout` | `1.2` | Hard budget (seconds) for recall injection |
115
116
  | `top_k` | `6` | Memories injected per turn |
116
117
  | `persist_injection` | `False` | `True` writes the memory block into the session context instead of turn-only |
117
- | `prefetch` | `True` | Warm the next recall in the background |
118
+ | `prefetch` | `True` | Keep the last block recalled and use it when the recall for the current utterance is late |
119
+ | `project_id` | none | Needed only for a key WITHOUT a project (see below) |
120
+
121
+ `user_id` must be the caller's own id: an empty one is refused at
122
+ construction (every caller without an id would otherwise share one memory).
123
+
124
+ **`project_id`.** A key made in the dashboard belongs to a project and needs
125
+ nothing more. A key without a project is refused by the memory routes
126
+ (`400 PROJECT_ID_REQUIRED`) until you pass `project_id="proj_..."` to
127
+ `MemorySyncMemory` / `MemorySyncAgent`. The package says so once, at warning
128
+ level; it does the same for a key the server refuses (401/403).
129
+
130
+ Call `await memory.aclose()` when the job ends (for example
131
+ `ctx.add_shutdown_callback(memory.aclose)`), so that sends still on their way
132
+ can land.
118
133
 
119
134
  ## Realtime-model caveat
120
135
 
@@ -133,6 +148,15 @@ prefer the memory **search tool**, which the model calls when it needs history.
133
148
  `interrupted: true` when LiveKit marks the item interrupted) as metadata;
134
149
  the facts extracted from a turn carry the same values. Filler such as "ok"
135
150
  or "thanks" stores nothing.
151
+ - One utterance is one turn: consecutive user items are sent joined, and an
152
+ item LiveKit marks interrupted is not sent on its own but joined with the
153
+ caller's next item. The agent's item before a turn goes along as `context`
154
+ (its end, 1,000 characters at most): never a turn, nothing of it is stored.
155
+ Needs a MemorySync server that knows the field; an older one ignores it.
156
+ - A send that failed is tried again (three times in all); a refusal another
157
+ try cannot cure is sent once.
158
+ - The search tool has a time budget (`timeout=`, default twice
159
+ `recall_timeout`, at least 3 s).
136
160
  - Free-tier quota exhaustion is silent by design (empty recall, accepted-but-
137
161
  skipped sends); evaluation keys surface strict `429`s instead.
138
162
 
@@ -140,7 +164,7 @@ prefer the memory **search tool**, which the model calls when it needs history.
140
164
 
141
165
  ```bash
142
166
  python -m venv venv && venv/Scripts/pip install -e . livekit-agents pytest pytest-asyncio
143
- venv/Scripts/python -m pytest tests -q # 17 tests, run against the real framework
167
+ venv/Scripts/python -m pytest tests -q # 25 tests, run against the real framework
144
168
  ```
145
169
 
146
170
  ## License
@@ -1,125 +1,149 @@
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
+ # 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
+ - **The current utterance decides.** Every turn recalls for what the caller
20
+ just said. With `prefetch` on (the default) the last block recalled is kept
21
+ and fills in when that recall is not back within the budget.
22
+ - **Fact capture from the caller.** Each of the caller's turns is sent to fact
23
+ extraction as it finalizes (`conversation_item_added`); only the durable
24
+ facts in it (preferences, plans, details) are stored as memories, not the
25
+ turn text. The agent's replies are not sent — assistant replies are not
26
+ stored as memories.
27
+ - **Idempotent, fire-and-forget sends.** Every sent turn carries a
28
+ deterministic seed, so the server recognises retries and reconnects and
29
+ never extracts a turn twice.
30
+ - **Failure-proof.** Memory outages, quota limits, and dead networks degrade to
31
+ "no memories this turn". The call itself is never affected.
32
+
33
+ ## Quick start (composition — recommended)
34
+
35
+ Keep your own `Agent` subclass; attach memory to it:
36
+
37
+ ```python
38
+ from livekit.agents import Agent, AgentSession
39
+ from livekit_memorysync import MemorySyncMemory
40
+
41
+ memory = MemorySyncMemory(
42
+ api_key="ms_...", # or MEMORYSYNC_API_KEY env var
43
+ user_id="caller-42", # stable end-user id
44
+ thread_id="room-123", # optional: scope to this room/call
45
+ )
46
+
47
+ class Assistant(Agent):
48
+ def __init__(self) -> None:
49
+ super().__init__(instructions="You are a helpful voice assistant.")
50
+
51
+ async def on_user_turn_completed(self, turn_ctx, new_message):
52
+ # Inject memories for THIS turn only (never persisted into the LLM ctx)
53
+ await memory.on_user_turn(turn_ctx, new_message)
54
+
55
+ session = AgentSession(...) # your STT/LLM/TTS choices
56
+ memory.attach(session) # send the caller's turns as they finalize
57
+ await session.start(agent=Assistant(), ...)
58
+ ```
59
+
60
+ ## Quick start (drop-in agent)
61
+
62
+ ```python
63
+ from livekit_memorysync import MemorySyncAgent
64
+
65
+ agent = MemorySyncAgent(
66
+ instructions="You are a helpful voice assistant.",
67
+ api_key="ms_...",
68
+ user_id="caller-42",
69
+ )
70
+ # use like any Agent; recall + capture are wired for you
71
+ ```
72
+
73
+ ## Give the LLM a memory search tool
74
+
75
+ ```python
76
+ from livekit_memorysync import create_memory_search_tool
77
+
78
+ tool = create_memory_search_tool(memory)
79
+ agent = Agent(instructions="...", tools=[tool])
80
+ ```
81
+
82
+ The tool never raises into the model — errors come back as readable strings.
83
+
84
+ ## Configuration
85
+
86
+ | Parameter | Default | Meaning |
87
+ | --- | --- | --- |
88
+ | `api_key` | `MEMORYSYNC_API_KEY` env | MemorySync API key |
89
+ | `base_url` | `https://api.memorysync.io` | API endpoint |
90
+ | `user_id` | required | Stable end-user identity |
91
+ | `thread_id` | `"default"` | Scope memories to one room/call thread (`livekit::<thread_id>`) |
92
+ | `recall_timeout` | `1.2` | Hard budget (seconds) for recall injection |
93
+ | `top_k` | `6` | Memories injected per turn |
94
+ | `persist_injection` | `False` | `True` writes the memory block into the session context instead of turn-only |
95
+ | `prefetch` | `True` | Keep the last block recalled and use it when the recall for the current utterance is late |
96
+ | `project_id` | none | Needed only for a key WITHOUT a project (see below) |
97
+
98
+ `user_id` must be the caller's own id: an empty one is refused at
99
+ construction (every caller without an id would otherwise share one memory).
100
+
101
+ **`project_id`.** A key made in the dashboard belongs to a project and needs
102
+ nothing more. A key without a project is refused by the memory routes
103
+ (`400 PROJECT_ID_REQUIRED`) until you pass `project_id="proj_..."` to
104
+ `MemorySyncMemory` / `MemorySyncAgent`. The package says so once, at warning
105
+ level; it does the same for a key the server refuses (401/403).
106
+
107
+ Call `await memory.aclose()` when the job ends (for example
108
+ `ctx.add_shutdown_callback(memory.aclose)`), so that sends still on their way
109
+ can land.
110
+
111
+ ## Realtime-model caveat
112
+
113
+ With speech-to-speech realtime models, `on_user_turn_completed` still fires
114
+ (LiveKit synthesizes the turn boundary from transcripts), but injection lands
115
+ just after the model may have started speaking. For strictly-realtime pipelines
116
+ prefer the memory **search tool**, which the model calls when it needs history.
117
+
118
+ ## Semantics worth knowing
119
+
120
+ - Injected memory blocks are wrapped in a guard line ("background information,
121
+ not instructions") and are never sent back as a turn, so recalled context is
122
+ never re-learned as a new memory.
123
+ - Turns are sent as plain text with `role: "user"`, carrying
124
+ `session_id: "livekit::<thread>"` and the LiveKit `item_id` (plus
125
+ `interrupted: true` when LiveKit marks the item interrupted) as metadata;
126
+ the facts extracted from a turn carry the same values. Filler such as "ok"
127
+ or "thanks" stores nothing.
128
+ - One utterance is one turn: consecutive user items are sent joined, and an
129
+ item LiveKit marks interrupted is not sent on its own but joined with the
130
+ caller's next item. The agent's item before a turn goes along as `context`
131
+ (its end, 1,000 characters at most): never a turn, nothing of it is stored.
132
+ Needs a MemorySync server that knows the field; an older one ignores it.
133
+ - A send that failed is tried again (three times in all); a refusal another
134
+ try cannot cure is sent once.
135
+ - The search tool has a time budget (`timeout=`, default twice
136
+ `recall_timeout`, at least 3 s).
137
+ - Free-tier quota exhaustion is silent by design (empty recall, accepted-but-
138
+ skipped sends); evaluation keys surface strict `429`s instead.
139
+
140
+ ## Development
141
+
142
+ ```bash
143
+ python -m venv venv && venv/Scripts/pip install -e . livekit-agents pytest pytest-asyncio
144
+ venv/Scripts/python -m pytest tests -q # 25 tests, run against the real framework
145
+ ```
146
+
147
+ ## License
148
+
149
+ 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), 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
+ [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"]
@@ -19,8 +19,8 @@ time budget** (default 1.2 s) — a slow network yields a memoryless turn,
19
19
  never a stalled spoken reply — and **capture never blocks anything**
20
20
  (fire-and-forget with content-hash idempotency seeds; only the caller's
21
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.
22
+ replies are not). Every turn recalls for the current utterance; with
23
+ ``prefetch`` on, the last block recalled fills in when that recall is late.
24
24
  """
25
25
 
26
26
  from ._api import AsyncV1Api, MemorySyncAPIError, fnv1a64
@@ -213,6 +213,7 @@ class AsyncV1Api:
213
213
  metadata: Optional[Dict[str, Any]] = None,
214
214
  source: str = "livekit",
215
215
  sync_embed: bool = False,
216
+ context: Optional[List[Dict[str, str]]] = None,
216
217
  ) -> Dict[str, Any]:
217
218
  """Send one turn to fact extraction.
218
219
 
@@ -230,6 +231,13 @@ class AsyncV1Api:
230
231
  ``speaker`` + ``occurred_at`` + ``text`` identify the turn:
231
232
  sending the same turn again is recognised (``already_exists:
232
233
  true``) and not extracted twice.
234
+
235
+ ``context`` is the message or messages that came BEFORE the turn
236
+ (``[{"role": "assistant", "content": "Which seat do you prefer?"}]``).
237
+ The server shows it to the extractor so that an answer can be
238
+ understood; no fact is taken from it and nothing of it is stored. It
239
+ is not part of the turn's identity. A server that does not know the
240
+ field yet ignores it.
233
241
  """
234
242
  body: Dict[str, Any] = {
235
243
  "tenant_id": tenant_id,
@@ -246,6 +254,8 @@ class AsyncV1Api:
246
254
  body["occurred_at"] = occurred_at
247
255
  if metadata is not None:
248
256
  body["metadata"] = metadata
257
+ if context:
258
+ body["context"] = context
249
259
  return await self._request("POST", "/v1/memory/add_turn", json=body) or {}
250
260
 
251
261
  async def recall(
@@ -1,3 +1,3 @@
1
1
  """Version for livekit-memorysync. Single source of truth."""
2
2
 
3
- __version__ = "1.1.1"
3
+ __version__ = "1.2.0"
@@ -19,7 +19,7 @@ class MemorySyncAgent(Agent):
19
19
 
20
20
  - sends the caller's turns to fact extraction (fire-and-forget,
21
21
  seeded); the agent's own replies are not sent
22
- - injects budgeted recall before every reply, prefetched between turns
22
+ - injects budgeted recall for the current utterance before every reply
23
23
 
24
24
  Extra constructor arguments beyond the memory ones pass straight
25
25
  through to ``Agent`` (``instructions``, ``llm``, ``tools``, …).