Skip to content

feat(memory): Add Valkey vector memory store#634

Open
edlng wants to merge 5 commits into
OpenBMB:mainfrom
edlng:add-valkey
Open

feat(memory): Add Valkey vector memory store#634
edlng wants to merge 5 commits into
OpenBMB:mainfrom
edlng:add-valkey

Conversation

@edlng

@edlng edlng commented Jun 8, 2026

Copy link
Copy Markdown

Summary

Adds a new valkey memory store type that uses Valkey Search's HNSW vector index for persistent, server-side memory with KNN retrieval. This gives users a self-hosted alternative to Mem0 for environments where cloud memory services aren't an option.

Issue

N/A

Changes

  • entity/configs/node/memory.py - New ValkeyMemoryConfig dataclass with from_dict parsing,
    validation (port range, db index, TTL), and FIELD_SPECS for the UI
  • runtime/node/agent/memory/valkey_memory.py - ValkeyMemory implementation: lazy-imports
    glide_sync, creates HNSW FT index on init, stores memories as Hashes with float32 embeddings, retrieves
    via FT.SEARCH KNN queries filtered by agent role, supports optional TTL via EXPIRE
  • runtime/node/agent/memory/builtin_stores.py - Registers valkey in the memory store registry with a
    lazy factory to avoid import-time dependency on valkey-glide-sync
  • pyproject.toml / uv.lock - Adds valkey-glide-sync>=2.4 as an optional dependency under
    [project.optional-dependencies] valkey
  • tests/test_valkey_memory.py - 738 lines of unit tests covering config parsing, validation edge cases,
    registry integration, tag sanitization, update/retrieve/count behavior, TTL handling, TLS/auth
    forwarding, and error paths
  • docs/user_guide/zh/modules/memory.md - Documents Valkey memory config fields, index behavior, and
    usage notes in the Chinese user guide
  • yaml_instance/demo_valkey_memory.yaml - Example workflow showing a memory-backed conversation agent
    using Valkey as the vector store

Tests

Full unit test suite in tests/test_valkey_memory.py. All Valkey interactions are mocked (no live server
required). Coverage includes:

  • Config parsing with valid/invalid inputs (port bounds, db bounds, TTL constraints)
  • Registry lookup and schema integration
  • ValkeyMemory instantiation, including idempotent index creation and error handling when the Search
    module is missing
  • update() with and without TTL, empty input short-circuit
  • retrieve() with threshold filtering, role-based FT.SEARCH queries, similarity ordering, empty query
    handling, and search errors
  • count_memories() success and failure paths
  • _sanitize_tag() edge cases

Blockers / Future work

  • No integration tests against a live Valkey instance yet (would need CI with valkey-bundle Docker image)

atao2004 and others added 5 commits June 5, 2026 08:40
* Add Valkey memory store scaffolding (config, registry, tests)

* Address PR feedback: port/db bounds, Docker note, collapse tests

* change required to True for port and host

* combine tests into one

* Revert host+port to required=False
Signed-off-by: Edward Liang <edward.liang@improving.com>
Signed-off-by: Edward Liang <edward.liang@improving.com>
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.

2 participants