Memory has no removal path: delete_session() leaves what add_session_to_memory() copied, and BaseMemoryService exposes no way to remove it
@surajksharma07 已经在做这个了。
开始于 2026年9月14日。
评估
这个 Issue 还没有评估数据。
描述
🔴 Required Information
Describe the Bug:
BaseSessionService has delete_session, implemented by all five session backends. BaseMemoryService has three ingestion methods and one search method, and no removal method at all:
BaseMemoryService public API: ['add_events_to_memory', 'add_memory',
'add_session_to_memory', 'search_memory']
Since add_session_to_memory() copies the session's content into the memory service, deleting the session leaves that copy in place with no API to remove it. A caller who deletes a session reasonably expects the conversation to be gone; it is still returned verbatim by search_memory().
The base class docstring describes the service as providing "functionality to ingest conversation history into memory so that it can be used for user queries" — it does not say the ingestion is one-way.
Steps to Reproduce:
pip install google-adk==2.9.0- Save the script under Minimal Reproduction Code as
repro.py python repro.py
Expected Behavior:
Either a way to remove what was ingested (for a session, a user, or a memory entry), or documentation stating that ingestion is one-way and that memory has to be cleaned up through the backend directly.
Observed Behavior:
before delete — in memory : True
after delete — session : gone
after delete — in memory : STILL THERE
retrieved verbatim : my-passport-number-is-AB1234567
BaseMemoryService public API: ['add_events_to_memory', 'add_memory', 'add_session_to_memory', 'search_memory']
any removal method? : False
The middle line is the negative control: the session really is deleted, so the surviving copy is the memory service's, not a stale session.
Environment Details:
- ADK Library Version:
google-adk 2.9.0 - Desktop OS: macOS 26.6.2 (arm64)
- Python Version: 3.12.13
Model Information:
- Are you using LiteLLM: No
- Which model is being used: N/A — no model is involved
🟡 Optional Information
Additional Context — scope, stated restrictively:
- This is a gap in the abstraction, not a runtime failure. Nothing raises, and
InMemoryMemoryServicebehaves exactly as written. - I have not checked whether the hosted backends (Vertex AI RAG, Memory Bank) offer deletion outside ADK through their own APIs or consoles. They may well do. The asymmetry I am reporting is in ADK's own surface: one store is deletable through the abstraction and the other is not, while one feeds the other.
- I am deliberately not proposing an API shape. Whether removal is keyed by session, by user, or by memory entry is a design decision, and
search_memoryresults do not currently carry an identifier that a delete call could take. - I am not raising any compliance or regulatory claim; that is yours to judge. I am only showing that the two lifecycles are asymmetric and that the docstring does not say so.
Minimal Reproduction Code:
"""delete_session() removes the session; what add_session_to_memory() copied stays,
and BaseMemoryService exposes no way to remove it."""
import asyncio, inspect
from google.genai import types
from google.adk.events.event import Event
from google.adk.sessions.in_memory_session_service import InMemorySessionService
from google.adk.memory.in_memory_memory_service import InMemoryMemoryService
from google.adk.memory.base_memory_service import BaseMemoryService
SECRET = 'my-passport-number-is-AB1234567'
async def main():
sessions, memory = InMemorySessionService(), InMemoryMemoryService()
s = await sessions.create_session(app_name='app', user_id='u1')
await sessions.append_event(s, Event(author='user', invocation_id='i1',
content=types.Content(role='user', parts=[types.Part(text=SECRET)])))
s = await sessions.get_session(app_name='app', user_id='u1', session_id=s.id)
await memory.add_session_to_memory(s)
hit = await memory.search_memory(app_name='app', user_id='u1', query='passport')
print('before delete — in memory :', bool(hit.memories))
await sessions.delete_session(app_name='app', user_id='u1', session_id=s.id)
gone = await sessions.get_session(app_name='app', user_id='u1', session_id=s.id)
print('after delete — session :', 'gone' if gone is None else 'STILL THERE') # negative control
hit = await memory.search_memory(app_name='app', user_id='u1', query='passport')
print('after delete — in memory :', 'STILL THERE' if hit.memories else 'gone')
if hit.memories:
print(' retrieved verbatim :', hit.memories[0].content.parts[0].text)
api = [n for n, _ in inspect.getmembers(BaseMemoryService, inspect.isfunction)
if not n.startswith('_')]
print('\nBaseMemoryService public API:', api)
print('any removal method? :',
any(k in n for n in api for k in ('delete','remove','purge','forget')))
asyncio.run(main())
How often has this issue occurred?:
- Always (100%) — deterministic; no model, no network, no timing involved.
- 主要语言
- Python
- 星标
- 21.6k
- 派生
- 4k
- 平均合并
- 13 小时 49 分钟
- 30 天内合并 PR
- 10
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
google/adk-python 的其他 Issue
-
mcp
难度 2/5 1-3 小时 新手友好度 75/100
google/adk-python#7217 · 2 条评论 · 已指派 1 人 ·
-
tools
难度 2/5 1-3 小时 新手友好度 78/100
google/adk-python#7206 · 1 条评论 · 已指派 1 人 ·
-
tools
难度 2/5 1-3 小时 新手友好度 86/100
google/adk-python#7205 · 1 条评论 · 已指派 1 人 ·
-
mcp
难度 2/5 1-3 小时 新手友好度 78/100
google/adk-python#7196 · 1 条评论 · 已指派 1 人 ·
-
eval request clarification
难度 1/5 1-3 小时 新手友好度 86/100
google/adk-python#7146 · 2 条评论 · 已指派 1 人 ·
查看 google/adk-python 的全部 Issue
相似的 Issue
-
triage/confirmed
难度 2/5 1-3 小时 新手友好度 88/100
agentscope-ai/agentscope#2775 ·
-
comp/desktop P3 type/bug
难度 1/5 1 小时以内 新手友好度 92/100
NousResearch/hermes-agent#118866 ·
-
bug
难度 1/5 1 小时以内 新手友好度 90/100
apache/cloudstack#14222 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
-
bug
难度 2/5 1-3 小时 新手友好度 82/100