delete_all_long_term_memories_in_namespace deletes only the first 10 records
维护者通常 1 天内回复
评估
调研方向
该错误位于 src/bedrock_agentcore/memory/session.py 中的 delete_all_long_term_memories_in_namespace,它调用 list_long_term_memory_records 时没有传入 max_results,因此应用了默认值 10。请阅读该方法及其调用的列表代码,了解分页在 max_results 处如何停止。完成标准是:命名空间中的所有记录都能跨页删除,并且单元测试包含超过 10 条记录,且只模拟 list_memory_records 的分页器。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
MemorySessionManager.delete_all_long_term_memories_in_namespace is documented to delete all long-term memory records in a namespace, but it deletes at most 10. It collects the records with list_long_term_memory_records(namespace=namespace) and does not pass max_results, so it gets the default of 10:
- https://github.com/aws/bedrock-agentcore-sdk-python/blob/3707a9fc6fd5032c1cd23e3f06464da5ed8a559f/src/bedrock_agentcore/memory/session.py#L1107-L1109
- https://github.com/aws/bedrock-agentcore-sdk-python/blob/3707a9fc6fd5032c1cd23e3f06464da5ed8a559f/src/bedrock_agentcore/memory/session.py#L964-L968 (default
max_results=10) - https://github.com/aws/bedrock-agentcore-sdk-python/blob/3707a9fc6fd5032c1cd23e3f06464da5ed8a559f/src/bedrock_agentcore/memory/session.py#L1013-L1021 (stops paging and truncates at
max_results)
The return value has 10 successfulRecords and an empty failedRecords, so the caller cannot tell that records were left behind.
To Reproduce
Steps to reproduce the behavior (boto3 client mocked, no AWS calls):
- Mock the data-plane client so
list_memory_recordsreturns 250 records in one namespace, over three pages. - Call
MemorySessionManager(...).delete_all_long_term_memories_in_namespace("actor/123/facts"). - See that 10 records are deleted with a single
batch_delete_memory_recordscall.
Script:
from unittest.mock import MagicMock, patch
from bedrock_agentcore.memory.session import MemorySessionManager
records = [{"memoryRecordId": f"rec-{i:03d}"} for i in range(250)]
client = MagicMock()
paginator = MagicMock()
paginator.paginate.return_value = [{"memoryRecordSummaries": records[i : i + 100]} for i in range(0, 250, 100)]
client.get_paginator.return_value = paginator
client.batch_delete_memory_records.side_effect = lambda memoryId, records: {
"successfulRecords": [{"memoryRecordId": r["memoryRecordId"]} for r in records],
"failedRecords": [],
}
with patch("boto3.Session") as sess:
sess.return_value.client.return_value = client
sess.return_value.region_name = "us-west-2"
mgr = MemorySessionManager(memory_id="mem-1", region_name="us-west-2")
result = mgr.delete_all_long_term_memories_in_namespace("actor/123/facts")
print("deleted:", len(result["successfulRecords"]), "failed:", len(result["failedRecords"]))
print("batch_delete calls:", client.batch_delete_memory_records.call_count)
Output:
deleted: 10 failed: 0
batch_delete calls: 1
Expected behavior
All 250 records are deleted, in three batch_delete_memory_records calls (the method already splits the IDs into chunks of 100).
Screenshots
N/A
Desktop (please complete the following information):
- OS: Linux
- Browser: N/A (Python SDK)
- Version: bedrock-agentcore 1.25.2 (main at 3707a9f), Python 3.12.8, boto3 1.43.123
Smartphone (please complete the following information):
N/A
Additional context
- The limit has been there since the method was added in #148. The existing unit tests patch
list_long_term_memory_records, so they never hit the default. - Proposed fix: read every page before deleting, either by passing an unbounded
max_resultsat L1109 or by iterating thelist_memory_recordspaginator in this method, plus a unit test with more than 10 records that mocks only the paginator. - Out of scope: whether this call should use
namespaceornamespace_path(the TODO added in #449). The fix keepsnamespace=namespaceunchanged.
I'd be happy to work on this if confirmed.
- 主要语言
- Python
- 星标
- 786
- 派生
- 163
- 平均合并
- 4 小时
- 30 天内合并 PR
- 22
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
aws/bedrock-agentcore-sdk-python 的其他 Issue
-
bug high-severity
难度 2/5 1-3 小时 新手友好度 72/100
aws/bedrock-agentcore-sdk-python#752 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
aws/bedrock-agentcore-sdk-python#751 · 1 个 reaction ·
维护者通常 1 天内回复
-
MPP: credential is always sent in Authorization, ignoring header="Payment-Authorization" in the challenge可能已有人在做 @abhiramshaji-cyber 于 24 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 68/100
aws/bedrock-agentcore-sdk-python#702 ·
维护者通常 1 天内回复
-
[Bug] update_message fails with parameter validation error when SessionMessage.message_id is a Strands positional integer index可能已有人在做 @citizen204 于 144 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
aws/bedrock-agentcore-sdk-python#556 ·
维护者通常 1 天内回复
-
CodeInterpreter should not require a region argument可能已有人在做 @citizen204 于 159 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
aws/bedrock-agentcore-sdk-python#511 ·
维护者通常 1 天内回复
查看 aws/bedrock-agentcore-sdk-python 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 88/100
snap-stanford/Biomni#380 ·
-
难度 2/5 1-3 小时 新手友好度 74/100
microsoft/playwright-python#3361 ·
维护者通常 1 天内回复
-
documentation priority: low size: S status: needs triage
难度 2/5 1-3 小时 新手友好度 74/100
cubrid-lab/sqlalchemy-cubrid#1397 ·
维护者通常 1 天内回复
-
documentation priority: low size: S status: needs triage
难度 2/5 1-3 小时 新手友好度 72/100
cubrid-lab/pycubrid#1307 ·
维护者通常 1 天内回复
-
[Bug]: Installer hides SSL certificate errors as bare URLError, and the suggested fix can't work未关闭bug
难度 2/5 1-3 小时 新手友好度 80/100
ShaftHQ/chaosengine-harness#143 ·
维护者通常 1 天内回复