Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

InMemoryMemoryService loses sessionless memories when a session ID equals its fallback bucket name

未关闭 适合新手
#7,711 1 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 4 天内回复

@llalitkumarrr 已经在做这个了。

开始于 2026年10月25日。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
backend

调研方向

先阅读 InMemoryMemoryService.add_events_to_memory() 和 add_session_to_memory(),然后比较它们在 google/adk/memory/in_memory_memory_service.py 中处理会话 ID 的方式。使用提供的操作序列重现冲突,并检查现有的 memory service 测试。当添加 ID 为 __unknown_session_id__ 的会话后,无会话 ID 添加的记忆仍得到保留时,任务即完成。

由索引模型根据 Issue 内容生成。

描述

Required Information

Describe the Bug:
InMemoryMemoryService.add_events_to_memory() maps an omitted session ID to the string __unknown_session_id__. InMemorySessionService also accepts that literal as an ordinary session ID. Passing that session to add_session_to_memory() replaces the same bucket, silently removing previously added sessionless memories.

Steps to Reproduce:

  1. Add an event without a session ID and confirm it is searchable.
  2. Create an empty session with ID __unknown_session_id__ through InMemorySessionService.
  3. Add that session to memory and search again using the code below.

Expected Behavior:
Adding an unrelated empty session should preserve existing sessionless memories, as it does with ordinary-session.

Observed Behavior:

ordinary-session: before=1, after=1
__unknown_session_id__: before=1, after=0

Environment Details:

  • ADK: source checkout of main at 12c7bed7661ccf942f0f6d3b62bed22a23ea0a85.
  • Desktop OS: macOS, arm64.
  • Python: 3.13.16.

Model Information:

  • LiteLLM: No.
  • Model: N/A; local memory/session services only.

Optional Information

Regression: Unknown; reproduced on current main.

Minimal Reproduction Code:

import asyncio
from google.adk.events import Event
from google.adk.memory.in_memory_memory_service import InMemoryMemoryService
from google.adk.sessions.in_memory_session_service import InMemorySessionService
from google.genai import types

async def run(session_id):
    memory = InMemoryMemoryService()
    await memory.add_events_to_memory(
        app_name="app", user_id="user",
        events=[Event(author="user", content=types.Content(
            parts=[types.Part(text="saffron")]))],
    )
    before = len((await memory.search_memory(
        app_name="app", user_id="user", query="saffron")).memories)
    session = await InMemorySessionService().create_session(
        app_name="app", user_id="user", session_id=session_id)
    await memory.add_session_to_memory(session)
    after = len((await memory.search_memory(
        app_name="app", user_id="user", query="saffron")).memories)
    print(f"{session_id}: before={before}, after={after}")

async def main():
    await run("ordinary-session")
    await run("__unknown_session_id__")

asyncio.run(main())

How often: Always for the sequence above.

Additional Context: This uses only public service methods, with no internal state mutation. The collision is within one app/user scope. The fallback bucket needs an identity that cannot alias a caller-provided session ID. No fix is included in this report.

主要语言
Python
星标
22k
派生
4.2k
平均合并
3 天 21 小时
30 天内合并 PR
6

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

google/adk-python 的其他 Issue

查看 google/adk-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。