fix(livekit): update document id and metadata

This commit is contained in:
Ishaan Gupta 2026-10-02 00:56:54 +05:30
parent b5d468b06e
commit 30af373aa7
4 changed files with 8 additions and 8 deletions

View file

@ -34,7 +34,7 @@ Identities that are not valid container tags are sanitized to a stable tag. Set
Set the attribute in the access token your backend issues. Do not grant the caller `canUpdateOwnMetadata`, or they could change the attribute and read another caller's memory.
One call is stored as a single document. Pass the LiveKit room name as `session_id`. The document id is `lk-<session_id>`, so a later update with the same id appends to that call instead of creating another.
One call is stored as a single document. Pass the LiveKit room name as `session_id`. The session id is the document's custom id, so a later update with the same id appends to that call instead of creating another.
Use one `SupermemoryLiveKit` per call. If you do rebind it, turns already captured stay with the caller who said them, and memory from the earlier caller is never shown to the new one.

View file

@ -108,7 +108,7 @@ memory = SupermemoryLiveKit(
| `query` | No | Yes | You only need memories related to this turn |
| `full` | Yes | Yes | Default |
One call is stored as a single document under custom id `lk-<session_id>`, so a reconnect with the same session id updates that document instead of creating another. Explicit `remember` calls are separate facts, processed immediately (usually recallable within a minute), and are not tied to the call document.
One call is stored as a single document whose custom id is the session id, so a reconnect with the same session id updates that document instead of creating another. Explicit `remember` calls are separate facts, processed immediately (usually recallable within a minute), and are not tied to the call document.
### When a call becomes recallable

View file

@ -282,7 +282,7 @@ class SupermemoryLiveKit:
"instant",
content=text,
container_tag=tag,
metadata={"source": "livekit", "kind": "explicit"},
metadata={"platform": "livekit", "kind": "explicit"},
),
timeout=4.0,
)
@ -479,7 +479,7 @@ class SupermemoryLiveKit:
content="\n".join(lines),
container_tag=messages[0]["tag"],
custom_id=messages[0]["custom_id"],
metadata={"source": "livekit", "kind": "conversation"},
metadata={"platform": "livekit", "kind": "conversation"},
)
async def _add(self, dreaming: str, **kwargs: Any) -> None:
@ -498,7 +498,7 @@ class SupermemoryLiveKit:
def _custom_id(self) -> str:
raw = self.session_id or self._generated_session
return to_identifier(f"lk-{raw}")
return to_identifier(raw)
def _detach(self) -> None:
session = self._session

View file

@ -358,9 +358,9 @@ class MemoryTests(unittest.TestCase):
stored = client.added[0]
self.assertEqual(stored["content"], "User: I like tea\nAssistant: Noted.")
self.assertEqual(stored["container_tag"], "user_1")
self.assertEqual(stored["custom_id"], to_identifier("lk-room 1"))
self.assertEqual(stored["custom_id"], to_identifier("room 1"))
self.assertNotIn("secret", stored["content"])
self.assertEqual(stored["metadata"]["source"], "livekit")
self.assertEqual(stored["metadata"]["platform"], "livekit")
self.assertEqual(stored["dreaming"], "instant")
def test_close_flushes_a_trailing_user_turn(self):
@ -559,7 +559,7 @@ class MemoryTests(unittest.TestCase):
asyncio.run(plugin.aclose())
self.assertEqual(len(client.added), 3)
self.assertEqual({call["custom_id"] for call in client.added}, {to_identifier("lk-room-4")})
self.assertEqual({call["custom_id"] for call in client.added}, {"room-4"})
def test_unscoped_tools_do_not_call_the_api(self):
client = FakeClient()