Skip to content

feat(memory): add global and session memory search - #665

Open
xiami762 wants to merge 2 commits into
devfrom
feat/memory-search
Open

feat(memory): add global and session memory search#665
xiami762 wants to merge 2 commits into
devfrom
feat/memory-search

Conversation

@xiami762

@xiami762 xiami762 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add persistent Memory and Session transcript search through the existing memory_search tool.
  • Keep embeddings opt-in while providing indexed keyword search, incremental reconciliation, and citations.

Key Changes

  • Add hybrid Memory search across file-backed Memory and persisted Session history, with source filtering and citation decoration.
  • Add incremental Memory file indexing, Session transcript reconciliation, chunking, embedding caching, and stale-index cleanup.
  • Persist searchable Session message and tool-part data and add the required SQLite storage helpers.
  • Add memory.search.embedding.enabled configuration, defaulting to false, and write the minimal Memory Search configuration on first run.
  • Add focused coverage for Memory scope handling, Session transcript search, configuration initialization, storage, and message-part persistence.

Impact Scope

  • User-visible behavior: Agents can use memory_search to retrieve durable Memory and, when requested, Session history with file/line citations.
  • Compatibility / migration: Existing Memory files and Sessions remain valid; search tables are created through the existing storage initialization path.
  • Configuration / environment: Adds optional memory.search.embedding settings. Embeddings are disabled by default and require no new secret unless enabled.
  • Dependencies: No new third-party dependencies.
  • Performance / resources: Adds incremental indexing and searchable Session storage. Embedding cost and network usage occur only when embeddings are enabled.
  • Security / permissions: Session transcripts and tool traces become searchable data. Review project/session ownership filters and the set of Memory paths included in each search scope.

Business Logic to Review

  • MemoryManager reconciliation and the boundary between Global Memory, Project Memory, Daily Memory, and Session history.
  • MemoryIndexer file discovery, project scoping, stale-file cleanup, and idempotent incremental updates.
  • Session transcript watermarks, tool-part serialization/truncation, deleted-message handling, and concurrent reconciliation.
  • Vector/FTS result merging, score normalization, source filters, and citation line ranges.

Why This Approach

  • Reuses the existing file-backed Memory model and memory_search interface instead of introducing a separate Memory CRUD tool.
  • Uses SQLite-backed incremental indexes so search remains available without embeddings and can add semantic recall when explicitly enabled.

Test Plan

  • uv run pytest tests/memory/test_memory_scope.py tests/memory/test_session_transcript_search.py tests/config/test_config_init.py tests/storage/test_storage.py tests/session/test_message_parts_persistence.py -q (94 passed)

Compatibility, Migration & Rollback

  • No manual migration is required; storage initialization creates the additional search structures.
  • Embeddings remain off by default. Roll back by reverting this PR; existing Memory Markdown files are unaffected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant