Skip to content

fix(memory): pass Redis username to the long-term memory client - #1205

Open
eric7h wants to merge 1 commit into
volcengine:mainfrom
eric7h:fix/redis-ltm-username
Open

eric7h wants to merge 1 commit into
volcengine:mainfrom
eric7h:fix/redis-ltm-username

Conversation

@eric7h

@eric7h eric7h commented Nov 4, 2026

Copy link
Copy Markdown

Problem

RedisLTMBackend builds its Redis client from host, port, db and password, but not username. RedisConfig.username (DATABASE_REDIS_USERNAME) is therefore ignored and the client always authenticates as the default user. With a Redis ACL account (non-default user), long-term memory cannot connect at all:

redis.exceptions.AuthenticationError: invalid username-password pair or user is disabled.

The Redis knowledge base backend (veadk/knowledgebase/backends/redis_backend.py) already passes username=self.redis_config.username, and veadk harness add --long-term-memory-username already writes DATABASE_REDIS_USERNAME for long-term memory (via BACKEND_ENV["redis"]), so the setting is accepted but has no effect.

Fix

  • Pass username=self.redis_config.username to Redis(...) in RedisLTMBackend._create_vector_index. The default is still None, so password-only setups behave exactly as before.
  • Add the username line to the long-term memory Redis section of the generated harness.yaml comments, matching the knowledge base section.

Verification

  • Local Redis Stack 7.4.0 with an ACL user (ACL SETUSER ltmuser on >ltmpass ~* &* +@all, default user protected by a different password), MockEmbedding:
    • main: save_memory("u1", ...) raises AuthenticationError: invalid username-password pair or user is disabled.
    • this branch: save and search_memory work; a password-only config (no username) also still works.
  • New tests/memory/long_term_memory_backends/test_redis_ltm_client.py (fake Redis, no server needed): both tests fail on main and pass with the fix.
  • uv run --extra dev pre-commit run --all-files: pass.
  • uv run --extra dev pytest -n 4 -m "not codex_smoke and not piagent_smoke": 8057 passed. The same 24 failures and 2 collection errors (Codex runtime / frontend / self-host sandbox tests that need local tooling) occur on unmodified main in this environment.

Independent of #1201 (which changes the index prefix in the same file); they touch different lines.

This PR was prepared with an AI coding agent; I authorized the submission.

RedisLTMBackend built its Redis client without the configured
username (DATABASE_REDIS_USERNAME / RedisConfig.username), so it always
authenticated as the default user. With a Redis ACL account the
connection failed with "invalid username-password pair". The Redis
knowledge base backend already passes it, and the harness CLI already
writes DATABASE_REDIS_USERNAME for long-term memory.

This branch has not been deployed

No deployments
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