delete_all_long_term_memories_in_namespace deletes only the first 10 records
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 75/100
Hướng nghiên cứu
Lỗi nằm trong delete_all_long_term_memories_in_namespace tại src/bedrock_agentcore/memory/session.py, hàm này gọi list_long_term_memory_records mà không truyền max_results, nên giá trị mặc định 10 được áp dụng. Hãy đọc phương thức đó và mã liệt kê mà nó gọi để xem việc phân trang dừng ở max_results như thế nào. Hoàn thành khi tất cả bản ghi trong một namespace được xóa qua mọi trang, kèm một unit test có hơn 10 bản ghi và chỉ mock paginator của list_memory_records.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 786
- Fork
- 163
- Merge trung bình
- 4 giờ
- Pull request đã merge (30 ngày)
- 22
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của aws/bedrock-agentcore-sdk-python
-
bug high-severity
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
aws/bedrock-agentcore-sdk-python#752 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
OpenAIConverseConverter restores an empty history when one blob or text payload fails to parseĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
aws/bedrock-agentcore-sdk-python#751 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
MPP: credential is always sent in Authorization, ignoring header="Payment-Authorization" in the challengeCó thể đã có người làm @abhiramshaji-cyber đã nhận 24 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
aws/bedrock-agentcore-sdk-python#702 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] update_message fails with parameter validation error when SessionMessage.message_id is a Strands positional integer indexCó thể đã có người làm @citizen204 đã nhận 144 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
aws/bedrock-agentcore-sdk-python#556 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
CodeInterpreter should not require a region argumentCó thể đã có người làm @citizen204 đã nhận 159 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
aws/bedrock-agentcore-sdk-python#511 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của aws/bedrock-agentcore-sdk-python
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
snap-stanford/Biomni#380 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
microsoft/playwright-python#3361 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation priority: low size: S status: needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
cubrid-lab/sqlalchemy-cubrid#1397 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation priority: low size: S status: needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
cubrid-lab/pycubrid#1307 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: Installer hides SSL certificate errors as bare URLError, and the suggested fix can't workĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
ShaftHQ/chaosengine-harness#143 ·
Maintainer thường phản hồi trong vòng 1 ngày