google / google/adk-python

No way to delete memories from a MemoryService

Đang mở
#6,949 3 bình luận 0 reaction 1 người được giao Được @sanketpatil06 nhận Xem trên GitHub
needs review services
Ngôn ngữ chính
Python
Star
21.5k
Fork
4k
Merge trung bình
1 ngày 14 giờ
Pull request đã merge (30 ngày)
37

Mô tả

### Is your feature request related to a specific problem?

`BaseSessionService` has `delete_session` and `BaseArtifactService` has `delete_artifact`, but `BaseMemoryService` only has `add_session_to_memory`, `add_events_to_memory`, `add_memory` and `search_memory`. Once something is written to memory there is no way to remove it through ADK.

This comes up when a user asks for their data to be deleted. Sessions and artifacts I can handle. Whatever was extracted into long-term memory I cannot, so I end up going around ADK and deleting straight from the backing store.

Most of the pieces are already there. `MemoryEntry` has an `id` field, and the Vertex API has `projects.locations.reasoningEngines.memories.delete`. `VertexAiMemoryBankService` just doesn't wrap it. It only uses `memories.create`, `memories.generate` and `memories.ingest_events`.

### Describe the Solution You'd Like

Two methods on `BaseMemoryService`:

```python
async def delete_memory(self, *, app_name: str, user_id: str, memory_id: str) -> None
async def delete_memories(self, *, app_name: str, user_id: str) -> None
```

First one deletes a single entry, second one everything stored for a user.

For `VertexAiMemoryBankService` both map onto `memories.delete`. `InMemoryMemoryService` keeps a dict so it's easy. Implementations that can't support it could raise `NotImplementedError`.

### Impact on your work

I'm building agents for users in the EU, where a deletion request has to be answered within a month. Right now the memory part of that is a manual step outside ADK, and it's the part I can't show was actually done.

### Willingness to contribute

Yes, happy to open a PR if you're OK with the method names and signatures.

### Describe Alternatives You've Considered

Deleting from the backing store directly. It works but it's different for every implementation and bypasses ADK completely. The other option is not using MemoryService at all.

### Version

google-adk 2.8.0

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.