Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/openai-sdk-python/src/supermemory_openai/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,12 @@ async def get_profile(

return ProfileResult(
success=True,
profile=_model_to_dict(response.profile),
# The API returns a null profile for a user with no memories yet.
profile=(
_model_to_dict(response.profile)
if response.profile is not None
else {"static": [], "dynamic": []}
),
search_results=(
_model_to_dict(response.search_results)
if response.search_results is not None
Expand Down
17 changes: 17 additions & 0 deletions packages/openai-sdk-python/tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,23 @@ async def test_get_profile_uses_client_profile(self):
q="tea",
)

@pytest.mark.asyncio
async def test_get_profile_handles_user_with_no_memories(self):
"""A null profile (new user, no memories yet) is an empty profile, not a failure."""
from types import SimpleNamespace
from unittest.mock import AsyncMock

tools = SupermemoryTools("test-key", {"container_tags": ["unit-tag"]})
tools.client.profile = AsyncMock(
return_value=SimpleNamespace(profile=None, search_results=None)
)

result = await tools.get_profile()

assert result["success"] is True
assert result["profile"] == {"static": [], "dynamic": []}
assert result["search_results"] is None

@pytest.mark.asyncio
async def test_document_list_uses_client_documents_list(self):
"""document_list must call client.documents.list with container tag."""
Expand Down