delete_all_long_term_memories_in_namespace deletes only the first 10 records

オープン 初心者向け
#727 コメント 0 件 リアクション 0 件 担当者 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 にあります。このメソッドは max_results を指定せずに list_long_term_memory_records を呼び出すため、デフォルト値の 10 が適用されます。そのメソッドと、それが呼び出す一覧取得のコードを読み、ページングが max_results でどのように停止するかを確認してください。完了条件は、namespace 内のすべてのレコードがページをまたいで削除されることです。単体テストには 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時間
マージ済み PR(30日)
22

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

aws/bedrock-agentcore-sdk-python のほかの issue

aws/bedrock-agentcore-sdk-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。