Skip to content

fix(demo): treat HTTP 202 Accepted as background-store success#239

Open
Fearvox wants to merge 1 commit into
EverMind-AI:mainfrom
Fearvox:fix/issue-93-handle-202-accepted
Open

fix(demo): treat HTTP 202 Accepted as background-store success#239
Fearvox wants to merge 1 commit into
EverMind-AI:mainfrom
Fearvox:fix/issue-93-handle-202-accepted

Conversation

@Fearvox
Copy link
Copy Markdown
Collaborator

@Fearvox Fearvox commented Jun 3, 2026

fix(demo): treat HTTP 202 Accepted as background-store success

Closes #93.

Problem

SimpleMemoryManager.store() (the demo client in
methods/EverCore/demo/utils/simple_memory_manager.py) called
response.json() on every non-error POST. When the EverCore memory API
runs extraction in the background it answers POST /api/v1/memories with
202 Accepted and an empty body. response.raise_for_status() passes the
202 through (2xx), then response.json() either raises or yields no status,
so store() drops into the failure branch and prints
❌ Storage failed: ... — even though the write was accepted. This is exactly
the symptom reported in #93: "Storage failed: Request accepted, processing in
background."

Fix

Add a 202 branch right after raise_for_status() and before response.json().
On 202 the demo prints a ⏳ Accepted … (Processing in background) notice and
returns True. No other behavior changes — non-202 success and error paths are
untouched.

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()

Test

Adds methods/EverCore/tests/test_simple_memory_manager.py, an offline
regression that monkeypatches httpx.AsyncClient to return a 202 response and
asserts store() returns True. No live EverCore stack, database, or network
is required.

Run it:

cd methods/EverCore
PYTHONPATH=src:. uv run pytest tests/test_simple_memory_manager.py -q
# 1 passed

Verified locally on this branch:

  • With the fix: 1 passed (exit 0).
  • Without the fix (negative control): 1 failed (exit 1) —
    '_AcceptedResponse' object has no attribute 'json' and the demo prints
    ❌ Storage failed, reproducing Storage failed: Request accepted, processing in background #93. This confirms the test exercises the
    fix rather than passing vacuously.

Scope

Two files, surgical:

  • methods/EverCore/demo/utils/simple_memory_manager.py (+10, the 202 branch only)
  • methods/EverCore/tests/test_simple_memory_manager.py (new, offline regression)

No production memory-layer code is touched; this is demo-client robustness plus
its regression test.

Credit

The 202-handling approach matches upstream PR
#211
("fix: handle 202 Accepted response in demo store method") by @haifengqiu (梓宏),
credited on the commit via Co-authored-by.


🤖 Generated with Claude Code

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) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 3, 2026 02:40
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Storage failed: Request accepted, processing in background

2 participants