delete_all_long_term_memories_in_namespace deletes only the first 10 records

未關閉 適合新手
#727 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@Fire162 已經在處理了。

開始於 2026年11月2日。

  • #729 來自 @Fire162 —— 未關閉

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
75/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
aws, python
領域
backend

研究方向

此錯誤位於 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 內容生成。

描述

bug high-severity

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:

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):

  1. Mock the data-plane client so list_memory_records returns 250 records in one namespace, over three pages.
  2. Call MemorySessionManager(...).delete_all_long_term_memories_in_namespace("actor/123/facts").
  3. See that 10 records are deleted with a single batch_delete_memory_records call.

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_results at L1109 or by iterating the list_memory_records paginator 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 namespace or namespace_path (the TODO added in #449). The fix keeps namespace=namespace unchanged.

I'd be happy to work on this if confirmed.

主要語言
Python
星號
786
分支
163
平均合併
4 小時
30 天內合併 PR
22

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

aws/bedrock-agentcore-sdk-python 的其他 Issue

查看 aws/bedrock-agentcore-sdk-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。