VertexAiRagMemoryService drops distinct events that share a timestamp

未关闭
#8,209 1 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 3 天内回复

@sanketpatil06 已经在做这个了。

开始于 2026年11月18日。

  • #8211 来自 @sumedh-aerram —— 未关闭

评估

这个 Issue 还没有评估数据。

描述

services

search_memory loses distinct events from separate retrieved chunks of the same session when their timestamps match. _merge_event_lists uses timestamps for deduplication, although uploaded transcript lines also store author and text.

Expected: both the question and the answer containing ORCHID are returned, in order. Actual on upstream/main: only the question is returned. Exact copies from overlapping chunks should still appear once.

Offline reproduction (mocked RAG listing and retrieval; no credentials, model, or cloud service).

The final assertion fails on main:

import asyncio
import json
from types import SimpleNamespace as NS
from unittest.mock import AsyncMock, patch

from google.adk.memory.vertex_ai_rag_memory_service import VertexAiRagMemoryService


async def main():
    service = VertexAiRagMemoryService(rag_corpus="corpus")
    events = [("user", "What is the launch code?"),
              ("model", "The launch code is ORCHID.")]
    contexts = [NS(source_display_name="demo.alice.session", text=json.dumps({
        "author": author, "timestamp": 1700000000.0, "text": text,
    })) for author, text in events]
    client = NS(rag=NS(
        list_files=AsyncMock(side_effect=PermissionError("offline")),
        retrieve_contexts=AsyncMock(return_value=NS(contexts=NS(contexts=contexts))),
    ))
    with patch("agentplatform.Client", return_value=NS(aio=client)):
        response = await service.search_memory(
            app_name="demo", user_id="alice", query="launch code")
    actual = [(m.author, m.content.parts[0].text) for m in response.memories]
    print(actual)
    assert actual == events


asyncio.run(main())

Environment: ADK main (2.14.1), Python 3.11.17. Regression introduction unknown. Deterministic offline case.

Suggested fix: retain timestamp-based overlap grouping and stable ordering, but deduplicate using (timestamp, author, text). Parsed Event IDs are regenerated and cannot identify overlapping copies.

主要语言
Python
星标
22.3k
派生
4.4k
平均合并
1 天 2 小时
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 摘要。