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
10 changes: 10 additions & 0 deletions methods/EverCore/demo/utils/simple_memory_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ async def store(self, content: str, sender: str = "User") -> bool:
async with httpx.AsyncClient(timeout=500.0) as client:
response = await client.post(self.memorize_url, json=payload)
response.raise_for_status()

# Background mode returns 202 Accepted (memory extraction
# continues asynchronously). Treat it as success instead of
# falling through to result.json() and reporting a failure.
if response.status_code == 202:
print(
f" ⏳ Accepted: {content[:40]}... (Processing in background)"
)
return True

result = response.json()

# v1 response: {"data": {"status": "...", "count": N, ...}}
Expand Down
40 changes: 40 additions & 0 deletions methods/EverCore/tests/test_simple_memory_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import pytest

from demo.utils.simple_memory_manager import SimpleMemoryManager


class _AcceptedResponse:
status_code = 202

def raise_for_status(self):
return None


class _AsyncClient:
def __init__(self):
self.posts = []

async def __aenter__(self):
return self

async def __aexit__(self, *args):
return False

async def post(self, url, json):
self.posts.append((url, json))
return _AcceptedResponse()


@pytest.mark.asyncio
async def test_store_treats_accepted_background_response_as_success(monkeypatch):
client = _AsyncClient()
monkeypatch.setattr(
'demo.utils.simple_memory_manager.httpx.AsyncClient',
lambda *args, **kwargs: client,
)

manager = SimpleMemoryManager(user_id='user-1')
manager._settings_initialized = True

assert await manager.store('background extraction') is True
assert len(client.posts) == 1