test(agent-framework): add_memory must not reuse the conversation document id

Add tests to ensure unique document IDs for memory entries.
This commit is contained in:
harshitgavita-07 2026-10-02 23:55:19 +05:30 • committed by GitHub
parent f4245fdad2
commit 00c02db176
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -47,3 +47,31 @@ class TestSupermemoryTools:
conn = _make_conn(conversation_id="conv-123")
tools = SupermemoryTools(conn)
assert tools._connection.custom_id == "conversation_conv-123"
class _RecordingClient:
def __init__(self) -> None:
self.add_calls: list[dict] = []
async def add(self, **kwargs):
self.add_calls.append(kwargs)
return {"id": f"doc-{len(self.add_calls)}", "status": "queued"}
class TestAddMemoryDocumentIdentity:
@pytest.mark.asyncio
async def test_add_memory_does_not_reuse_conversation_document_id(self) -> None:
conn = _make_conn(conversation_id="conv-123")
tools = SupermemoryTools(conn)
client = _RecordingClient()
tools._client = client
await tools.add_memory("The user likes green tea.")
await tools.add_memory("The user lives in Lisbon.")
assert len(client.add_calls) == 2
# A shared custom_id makes Supermemory treat every call as an update of one
# document, so the second memory replaces the first and both collide with the
# conversation transcript saved under the same id.
assert all(call.get("custom_id") != conn.custom_id for call in client.add_calls)
assert all(call["container_tag"] == "msft_agent_chat" for call in client.add_calls)