You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MemorySession.get_last_k_turns(branch_name=...) fails with ParamValidationError for includeParentBranches=None #760
Describe the bug MemorySession.get_last_k_turns() defaults include_parent_branches to None. When a branch_name other than "main" is passed, MemorySessionManager.get_last_k_turns() puts that value into the list_events branch filter. boto3 requires includeParentBranches to be a bool, so the call fails before any request is sent:
botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid type for parameter filter.branch.includeParentBranches, value: None, type: <class 'NoneType'>, valid types: <class 'bool'>
So reading the last turns of a branch through a MemorySession does not work unless the caller also passes include_parent_branches explicitly. The equivalent MemorySession.list_events(branch_name=...) works, because its default is False.
Expected behavior session.get_last_k_turns(k=3, branch_name="alt") returns the turns of branch alt (here []), the same as manager.get_last_k_turns(actor_id, session_id, k=3, branch_name="alt").
Root cause src/bedrock_agentcore/memory/session.py:1236 (MemorySession.get_last_k_turns):
include_parent_branches: Optional[bool] =None,
It is passed straight to MemorySessionManager.get_last_k_turns, which builds {"branch": {"name": branch_name, "includeParentBranches": include_parent_branches}} (session.py:814-815). The manager method and MemorySession.list_events both default to False. The None default came in with #108.
Environment
bedrock-agentcore 1.28.0 (main at 9ab8cea). Affected since v1.0.0.
Python 3.12, boto3/botocore current.
Additional context
Fix: change the default to include_parent_branches: bool = False. A tested fix with a Stubber-based regression test is ready on branch chaitanya0305:fix/memory-session-get-last-k-turns-parent-branches.
Activity