feat(memory): add Redis and OpenSearch long-term memory backends#49
Merged
sjy3 merged 1 commit intovolcengine:mainfrom Mar 10, 2026
Merged
Conversation
- Add RedisMemoryBackend using Redis Stack vector search (FT.SEARCH KNN) - Add OpenSearchMemoryBackend using knn_vector mapping with HNSW - Add shared EmbeddingConfig to decouple embedding model setup - Add RedisConfig and OpenSearchConfig to configs/database.go - Register DATABASE_REDIS_* and DATABASE_OPENSEARCH_* env key constants - Extend NewLongTermMemoryService factory with redis and opensearch cases - Add full unit test coverage for both backends using mockey
Collaborator
|
LGTM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add Redis (via Redis Stack / RediSearch) and OpenSearch backends for long-term memory in VeADK-Go, closing the feature gap with the Python SDK.
Both backends implement the existing
LongTermMemoryBackendinterface and use vector similarity search (KNN) backed by the ARK Embedding model, mirroring the VikingDB backend pattern.Motivation
The Python SDK already provides
redisandopensearchlong-term memory backends (via LlamaIndex VectorStore). This PR brings parity to the Go SDK.Changes
New files
memory/long_term_memory_backends/embedding_config.goEmbeddingConfigstruct that decouples embedding model setup from individual backends. Reads model name / API key / dimensions from globalVeADKConfigby default, or accepts explicit values.memory/long_term_memory_backends/redis_backend.goRedisMemoryBackend— stores memories as Redis Hash entries with aFLOAT32vector field and retrieves them viaFT.SEARCHKNN query (requires Redis Stack).memory/long_term_memory_backends/redis_backend_test.gogithub.com/bytedance/mockey).memory/long_term_memory_backends/opensearch_backend.goOpenSearchMemoryBackend— creates per-user indices withknn_vectorHNSW mapping and stores/retrieves memories via the OpenSearch REST API. Supports SSL/TLS with optional custom CA cert.memory/long_term_memory_backends/opensearch_backend_test.goModified files
common/consts.goDATABASE_REDIS_*andDATABASE_OPENSEARCH_*env key constantsconfigs/database.goRedisConfigandOpenSearchConfigstructs; map env vars inMapEnvToConfigconfigs/configs.goRedisandOpenSearchconfig structs inSetupVeADKConfigmemory/long_term_memory.goNewLongTermMemoryServicefactory withBackendLongTermRedisandBackendLongTermOpenSearchcasesmemory/long_term_memory_test.gogo.mod/go.sumgithub.com/redis/go-redis/v9 v9.18.0Usage
Redis backend
Requires Redis Stack (or Redis with the RediSearch module) which supports
FT.CREATE/FT.SEARCH.Via environment variables:
Via
config.yaml:In code:
OpenSearch backend
Via environment variables:
Via
config.yaml:In code:
Testing
No real databases are required — all external calls are mocked via
github.com/bytedance/mockey.Notes
SaveMemory/SearchMemory).<index>_<userId>) for OpenSearch and key-prefix scoping (<index>:<userId>:<uuid>) for Redis.knnplugin (included in OpenSearch >= 1.0 by default).mockeyfor tests,utils.GetEnvWithDefaultfor config, andNewDefaultEmbeddingConfigfor zero-config startup.