VertexAiRagMemoryService drops distinct events that share a timestamp

Offen
#8,209 1 Kommentar 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

Maintainer antworten meist innerhalb von 3 Tagen

@sanketpatil06 arbeitet bereits daran.

Seit 18.11.2026.

  • #8211 von @sumedh-aerram — offen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Beschreibung

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.

Vorherrschende Sprache
Python
Sterne
22.3k
Forks
4.4k
Ø Merge
1 T. 2 Std.
Gemergte PRs (30 T.)
6

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus google/adk-python

Alle Issues in google/adk-python

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.