Pipecat integration keeps previous memories after an empty recall

Aperta Adatta ai principianti
#7,050 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
88/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
ai, backend

Direzione di ricerca

Inizia da _handle_context_frame in hindsight-integrations/pipecat/hindsight_pipecat/memory.py e dal test di recupero vuoto in hindsight-integrations/pipecat/tests/test_memory.py. Riproduci il caso a due turni dell’issue, poi verifica come cambia il LLMContext condiviso quando il recupero non restituisce risultati. Il lavoro è completo quando il secondo contesto inoltrato conserva l’istruzione di base e la conversazione, ma non contiene alcun blocco di memoria della prima query.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

integration
Bug Description

HindsightMemoryService can leave the previous query's <hindsight_memories> system message in a reused Pipecat LLMContext after a successful recall returns zero results. The next prompt then carries the old recall result along with the new user message.

Steps to Reproduce

From hindsight-integrations/pipecat on c828c7e41527d0c4916cac0ba2b56334fed4a79d, run uv sync --frozen --python 3.12, save this as repro.py, then run uv run --no-sync python repro.py. No service credentials or network calls are needed for the repro.

import asyncio
from types import SimpleNamespace
from unittest.mock import AsyncMock

from hindsight_pipecat import HindsightMemoryService
from pipecat.frames.frames import LLMContextFrame
from pipecat.processors.aggregators.llm_context import LLMContext
from pipecat.processors.frame_processor import FrameDirection


async def main():
    client = SimpleNamespace(arecall=AsyncMock(side_effect=[
        SimpleNamespace(results=[SimpleNamespace(text="MARKER_FROM_FIRST_QUERY")]),
        SimpleNamespace(results=[]),
    ]))
    processor = HindsightMemoryService(bank_id="test", client=client, enable_retain=False)
    processor.push_frame = AsyncMock()
    context = LLMContext(messages=[{"role": "system", "content": "Base instruction"}])
    context.add_message({"role": "user", "content": "First query"})
    await processor.process_frame(LLMContextFrame(context), FrameDirection.DOWNSTREAM)
    assert "MARKER_FROM_FIRST_QUERY" in str(context.messages)

    context.add_message({"role": "assistant", "content": "First answer"})
    context.add_message({"role": "user", "content": "Unrelated second query"})
    await processor.process_frame(LLMContextFrame(context), FrameDirection.DOWNSTREAM)
    assert client.arecall.await_args.kwargs["query"] == "Unrelated second query"
    assert processor.push_frame.await_count == 2
    assert {"role": "system", "content": "Base instruction"} in context.messages
    assert "MARKER_FROM_FIRST_QUERY" not in str(context.messages), context.messages


asyncio.run(main())
Expected Behavior

After the empty recall, forward the second turn with the base system instruction and conversation intact and no Hindsight memory block from the first query.

Actual Behavior

The last assertion fails. The forwarded context still includes 1. MARKER_FROM_FIRST_QUERY, followed by the original instruction and conversation. The second recall received the correct query and returned an empty list.

_handle_context_frame only changes the shared context when recall returns text. Clearing the integration-owned block when recall returns empty would keep the context aligned with the latest query. The existing empty-recall test starts with a fresh context. A two-turn case catches the stale block.

Version

Hindsight Pipecat integration 0.1.2 at c828c7e4, locked Pipecat 1.12.0, CPython 3.12.13 on Windows. The existing tests/test_memory.py passed all 19 tests. The reproduction uses real Pipecat frame/context objects and mocks Hindsight recall and downstream delivery. No LLM provider was used.

Lingua principale
Python
Stelle
45.2k
Fork
5.9k
Merge medio
5h 57m
PR unite (30g)
351

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di vectorize-io/hindsight

Tutte le issue di vectorize-io/hindsight

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.