Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/bedrock_agentcore/memory/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,15 +653,19 @@ def list_events(
if next_token:
params["nextToken"] = next_token

# Initialize the filterMap
filterMap = {}

# Add branch filter if specified (but not for "main")
if branch_name and branch_name != "main":
params["filter"] = {
"branch": {"name": branch_name, "includeParentBranches": include_parent_branches}
}
filterMap["branch"] = {"name": branch_name, "includeParentBranches": include_parent_branches}

# Add eventMetadata filter if specified
if eventMetadata:
params["filter"] = {"eventMetadata": eventMetadata}
filterMap["eventMetadata"] = eventMetadata

if filterMap:
params["filter"] = filterMap

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

Expand Down
4 changes: 2 additions & 2 deletions tests/bedrock_agentcore/memory/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -2505,8 +2505,8 @@ def test_list_events_with_both_branch_and_metadata_filters(self):
call_args = mock_client_instance.list_events.call_args[1]
assert "filter" in call_args
assert call_args["filter"]["eventMetadata"] == event_metadata_filter
# Branch filter should not be present when eventMetadata is specified
assert "branch" not in call_args["filter"]
# Branch filter should be present when eventMetadata is specified
assert "branch" in call_args["filter"]

def test_memory_session_list_events_with_event_metadata(self):
"""Test MemorySession.list_events with eventMetadata parameter."""
Expand Down