From 6a51494a53524f995e63f7d558d24f6d0e44b0fa Mon Sep 17 00:00:00 2001 From: 0xVox Date: Tue, 2 Jun 2026 17:17:36 -0700 Subject: [PATCH] fix(demo): treat HTTP 202 Accepted as background-store success MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SimpleMemoryManager.store() called response.json() on every successful POST. When the EverCore memory API runs background extraction it replies 202 Accepted with no JSON body, so store() fell into the failure path and printed "Storage failed", even though the write was accepted. Add a 202 branch that returns True with a 'processing in background' notice before parsing the body. Closes #93. Adds tests/test_simple_memory_manager.py, an offline regression that mocks httpx.AsyncClient to return 202 and asserts store() returns True (no live stack required). Co-authored-by: 梓宏 <41323770+haifengqiu@users.noreply.github.com> Co-Authored-By: Claude Opus 4.8 (1M context) --- .../demo/utils/simple_memory_manager.py | 10 +++++ .../tests/test_simple_memory_manager.py | 40 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 methods/EverCore/tests/test_simple_memory_manager.py diff --git a/methods/EverCore/demo/utils/simple_memory_manager.py b/methods/EverCore/demo/utils/simple_memory_manager.py index 93898d22..0eee6ffe 100644 --- a/methods/EverCore/demo/utils/simple_memory_manager.py +++ b/methods/EverCore/demo/utils/simple_memory_manager.py @@ -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, ...}} diff --git a/methods/EverCore/tests/test_simple_memory_manager.py b/methods/EverCore/tests/test_simple_memory_manager.py new file mode 100644 index 00000000..c5760fcc --- /dev/null +++ b/methods/EverCore/tests/test_simple_memory_manager.py @@ -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