The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.
Python agentic-memoryagentic-memory-systemagentsaiai-agentschatgptgenaillmlong-term-memorymemorymemory-managementpythonragstate-management
fix(api): map entity params to filters in GET /memories (#4955) (#4960)
Pratik Rai693e70938952
diff --git a/server/main.py b/server/main.pyindex 9bafabf83..07d300d00 100644--- a/server/main.py+++ b/server/main.py@@ -395,10 +395,10 @@ def get_all_memories(try:if not any([user_id, run_id, agent_id]):return _list_all_memories()- params = {+ filters = {k: v for k, v in {"user_id": user_id, "run_id": run_id, "agent_id": agent_id}.items() if v is not None}- return get_memory_instance().get_all(**params)+ return get_memory_instance().get_all(filters=filters)except Exception:raise upstream_error()diff --git a/tests/test_server_params.py b/tests/test_server_params.pyindex 5e2224974..54d6e1638 100644--- a/tests/test_server_params.py+++ b/tests/test_server_params.py@@ -561,3 +561,30 @@ class TestUpdateOpenAPISchema:schema = client.get("/openapi.json").json()update_props = schema["components"]["schemas"]["MemoryUpdate"]["properties"]assert "metadata" in update_props++# ===========================================================================+# GetMemories: Entity parameters to filters mapping (fix for #4955)+# ===========================================================================++class TestGetMemories:+ """Verify that GET /memories correctly maps entity parameters to the filters dict."""++ def test_get_memories_entity_filters_routing(self, client, mock_memory):+ """+ Issue #4955: Test that the GET /memories route correctly handles+ top-level entity parameters by mapping them to the filters dictionary+ instead of passing them as direct kwargs to get_all()+ """+ # Send a request with a valid top-level entity parameter+ response = client.get("/memories?user_id=test_routing_user")++ # 1. Verify the endpoint doesn't crash with a 500 error+ assert response.status_code == 200++ # 2. Verify the response is structured correctly+ data = response.json()+ assert isinstance(data, list)++ # 3. Verify the core logic: the param was mapped to the filters dict!+ _, kwargs = mock_memory.get_all.call_args+ assert kwargs["filters"] == {"user_id": "test_routing_user"}