Skip to content

[Bug][multi-agent-memory]: GET /memories returns superseded memories and turns Statewave errors into an empty list #495

Open

Description

@jy7lsna

Affected Component

statewave-multi-agent-memory — server.py (GET /memories)

Bug Description

Two problems in one small handler:

# server.py:326-334
@app.get("/memories", ...)
async def get_memories():
    """Return current active memories for the subject."""
    async with _sw() as sw:
        try:
            memories = await sw.search_memories(SUBJECT_ID)
            return {"memories": memories}
        except StatewaveError:
            return {"memories": []}
  1. Not "active" only. search_memories() (agents/base.py) returns timeline.memories, which includes superseded memories. The docstring says active, and the demo is all about stale facts being superseded, so returning them unmarked to API callers is misleading.
  2. Errors look like "no data". A Statewave 401/500/outage returns 200 {"memories": []}, which is indistinguishable from an empty subject.

Expected Behavior

/memories returns only status == "active" memories, and a Statewave failure returns 502 with the error.

Suggested fix

memories = [m for m in await sw.search_memories(SUBJECT_ID) if m.get("status", "active") == "active"]
...
except StatewaveError as e:
    raise HTTPException(status_code=502, detail=str(e))

(Or, if superseded ones are wanted, keep them and fix the docstring, but the error handling should change either way.) Add a test in tests/ with a stubbed client.

Steps to Reproduce

Run the demo (Bloomberg's 3.5% Stripe fact gets superseded by TechCrunch's 2.9%), then curl localhost:8000/memories → both the 3.5% and 2.9% facts are listed.

Environment

main @ 5c48f83.

Severity

Low.

Activity

  1. Imad2702 commented on Oct 14, 2026

    @Imad2702

    Hi, I am working on this.

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions