Skip to content

Focus extraction hybrid pre-search queries #1247

Description

@sentry-junior

Passive extraction pre-searched existing memories with the full user+tool transcript. That made hybrid retrieval less accurate and more expensive: embeddings and FTS ran over tool dumps and long session text instead of durable user evidence.

Current behavior

Gap

  • Extraction needs nearby existing memories for skip/supersede context.
  • The retrieval query should include this turn's instructions and ambient thread context, but not raw tool dumps.
  • Hybrid RRF performs well when each leg is a bounded top-k index probe, not when the query is a whole transcript or tool payload.

Impact

  • Worse candidate quality for passive extraction skip/dedup decisions
  • Unnecessary embedding + FTS cost on every completed session with tool output
  • Pressure to optimize by dropping a hybrid leg instead of fixing the query

Prior art

Proposal

Requested design implemented in #1246:

  1. Keep hybrid RRF for both searchMemories and recallMemories (no skip lexical if any vector hit).
  2. For extraction pre-search, query from this turn's run-actor instructions + ambient thread context (not tool dumps), capped around 1.5k chars, instructions first then leftover budget for context.
  3. Keep each retrieval leg bounded; tighten lexical rank candidates to a small hybrid window (hundreds, not thousands).
  4. Leave the full run transcript available to the extraction model; only the retrieval query is curated.
  5. Document selection rules in code comments so later sources (e.g. compact tool summaries / Luna rewrite) can be added deliberately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions