Skip to content

Commit 70e138d

Browse files
glsukkiSukruth Gowdru Lingaraju
andauthored
fix: list_events having branch & eventMetadata filter (#153)
Co-authored-by: Sukruth Gowdru Lingaraju <[email protected]>
1 parent 81faca1 commit 70e138d

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/bedrock_agentcore/memory/session.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -653,15 +653,19 @@ def list_events(
653653
if next_token:
654654
params["nextToken"] = next_token
655655

656+
# Initialize the filterMap
657+
filterMap = {}
658+
656659
# Add branch filter if specified (but not for "main")
657660
if branch_name and branch_name != "main":
658-
params["filter"] = {
659-
"branch": {"name": branch_name, "includeParentBranches": include_parent_branches}
660-
}
661+
filterMap["branch"] = {"name": branch_name, "includeParentBranches": include_parent_branches}
661662

662663
# Add eventMetadata filter if specified
663664
if eventMetadata:
664-
params["filter"] = {"eventMetadata": eventMetadata}
665+
filterMap["eventMetadata"] = eventMetadata
666+
667+
if filterMap:
668+
params["filter"] = filterMap
665669

666670
response = self._data_plane_client.list_events(**params)
667671

tests/bedrock_agentcore/memory/test_session.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2505,8 +2505,8 @@ def test_list_events_with_both_branch_and_metadata_filters(self):
25052505
call_args = mock_client_instance.list_events.call_args[1]
25062506
assert "filter" in call_args
25072507
assert call_args["filter"]["eventMetadata"] == event_metadata_filter
2508-
# Branch filter should not be present when eventMetadata is specified
2509-
assert "branch" not in call_args["filter"]
2508+
# Branch filter should be present when eventMetadata is specified
2509+
assert "branch" in call_args["filter"]
25102510

25112511
def test_memory_session_list_events_with_event_metadata(self):
25122512
"""Test MemorySession.list_events with eventMetadata parameter."""

0 commit comments

Comments
 (0)