This commit is contained in:
pawan 2026-08-27 01:08:31 +05:30 committed by GitHub
commit 43282ba554
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 2 deletions

View file

@ -179,7 +179,7 @@ class SupermemoryPipecatService(FrameProcessor):
if self.session_id:
add_params["custom_id"] = self.session_id
await self._supermemory_client.memories.add(**add_params)
await self._supermemory_client.add(**add_params)
except Exception as e:
logger.error(f"Error storing messages: {e}")

View file

@ -120,4 +120,30 @@ class TestSupermemoryPipecatNullProfile(unittest.IsolatedAsyncioTestCase):
"profile": {"static": [], "dynamic": []},
"search_results": [],
},
)
)
class _MockAddClient:
"""a client that only exposes the top-level add, not memories.add."""
def __init__(self):
self.add = AsyncMock(return_value=SimpleNamespace(id="doc_123"))
class TestSupermemoryPipecatStoreMessages(unittest.IsolatedAsyncioTestCase):
async def test_store_messages_calls_top_level_add(self) -> None:
# regression guard: supermemory 3.x moved add off client.memories to the
# top level. _store_messages must call client.add, not client.memories.add.
# the mock has no memories attribute, so a reverted call would raise,
# get swallowed by the fire-and-forget block, and add would never fire.
service = SupermemoryPipecatService(api_key="mock_key", user_id="user_123")
client = _MockAddClient()
service._supermemory_client = client
await service._store_messages([{"role": "user", "content": "hello"}])
client.add.assert_awaited_once()
_, kwargs = client.add.await_args
self.assertIn("content", kwargs)
self.assertEqual(kwargs["container_tags"], ["user_123"])
self.assertFalse(hasattr(client, "memories"))