bug: incorrect pagination in Memory Session Manager `list_messages`
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 58/100
Research direction
Start in session_manager.py at list_messages and inspect how memory_client.list_events applies max_results and how events_to_messages discards state events. Reproduce the case with shared actor IDs and session or agent state events, then add unit or integration coverage; done means pagination returns the requested messages or exposes a nextToken when more messages exist.
Written by the indexing model from the issue text.
Description
Problem
Before PR #244
State events and conversational events were naturally separated by actorId:
# create_session used a prefixed actorId
create_event(actorId="session_my-session-id", payload=[{"blob": ...}])
# create_agent used a prefixed actorId
create_event(actorId="agent_my-agent-id", payload=[{"blob": ...}])
# create_message used the regular actorId
create_event(actorId="my-actor-id", payload=[{"conversational": ...}])
So when list_messages called list_events with actorId="my-actor-id", it only got conversational events back. State events lived under different actorIds and were invisible to this query. max_results counted only
what mattered.
After PR #244
Everything now uses the same actorId, with metadata distinguishing state events:
# create_session — same actorId, metadata marks it as state
create_event(
actorId="my-actor-id", # ← same as messages now
metadata={"stateType": {"stringValue": "SESSION"}},
payload=[{"blob": ...}],
)
# create_agent — same actorId, metadata marks it as state
create_event(
actorId="my-actor-id", # ← same as messages now
metadata={"stateType": {"stringValue": "AGENT"}, "agentId": {"stringValue": "..."}},
payload=[{"blob": ...}],
)
# create_message — same actorId, no metadata
create_event(actorId="my-actor-id", payload=[{"conversational": ...}])
Potential Issues
list_messages in session_manager.py fetches events without any metadata filter:
events = self.memory_client.list_events(
memory_id=self.config.memory_id,
actor_id=self.config.actor_id,
session_id=session_id,
max_results=max_results, # ← this now includes state events in the count
)
Since all events share the same actorId now, this query returns both conversational AND state events. The API returned max_results events total, some of which were state events. Those get discarded by the converter, so the final list is shorter than what the caller asked for.
Concrete example
A session with 1 session state event, 2 agent state events, and 20 conversational messages. Customer calls list_messages(limit=10):
max_results= limit + offset = 10list_eventsreturns 10 events: 3 state + 7 conversationalevents_to_messagesdiscards the 3 state events → 7 messages- Customer gets 7 messages, expected 10
Customer does not get a pagination token, so they assume 7 is all that exists, and doesn't know there are more.
Acceptance Criteria
- customer should be given nextToken, or should always get maxResults exactly if more results exist.
- unit tests and/or integration verifying fix of the bug.
- Dominant language
- Python
- Stars
- 786
- Forks
- 163
- Avg merge
- 4h
- Merged PRs (30d)
- 22
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from aws/bedrock-agentcore-sdk-python
-
bug high-severity
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
aws/bedrock-agentcore-sdk-python#752 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
aws/bedrock-agentcore-sdk-python#751 · 1 reaction ·
Maintainers usually reply within 1 day
-
delete_all_long_term_memories_in_namespace deletes only the first 10 recordsPossibly taken @Fire162 claimed this 18 days ago. Openbug high-severity
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
aws/bedrock-agentcore-sdk-python#727 ·
Maintainers usually reply within 1 day
-
MPP: credential is always sent in Authorization, ignoring header="Payment-Authorization" in the challengePossibly taken @abhiramshaji-cyber claimed this 24 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
aws/bedrock-agentcore-sdk-python#702 ·
Maintainers usually reply within 1 day
-
[Bug] update_message fails with parameter validation error when SessionMessage.message_id is a Strands positional integer indexPossibly taken @citizen204 claimed this 144 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
aws/bedrock-agentcore-sdk-python#556 ·
Maintainers usually reply within 1 day
All issues in aws/bedrock-agentcore-sdk-python
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
snap-stanford/Biomni#380 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
microsoft/playwright-python#3361 ·
Maintainers usually reply within 1 day
-
documentation priority: low size: S status: needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
cubrid-lab/sqlalchemy-cubrid#1397 ·
Maintainers usually reply within 1 day
-
documentation priority: low size: S status: needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
cubrid-lab/pycubrid#1307 ·
Maintainers usually reply within 1 day
-
[Bug]: Installer hides SSL certificate errors as bare URLError, and the suggested fix can't workOpenbug
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
ShaftHQ/chaosengine-harness#143 ·
Maintainers usually reply within 1 day