From a6e24ea075699f492e09fcf460cbc923376b8510 Mon Sep 17 00:00:00 2001 From: GitHub Copilot Date: Tue, 26 May 2026 22:20:27 -0400 Subject: [PATCH 1/2] Python: Add CLIENT SETNAME to Valkey/Redis connector for connection identification Fixes #14038 Summary: - Added client_name parameter to Redis.from_url() calls in RedisCollection class - Added client_name parameter to Redis.from_url() calls in RedisStore class - Client name set to 'semantic_kernel_vector_store_client' following the suggested naming pattern Why This Matters: When monitoring a Valkey server with multiple connected applications, CLIENT LIST shows each connection's name. Without a client name, operators cannot distinguish Semantic Kernel connections from other anonymous clients. This is especially important in production environments with ElastiCache where multiple services share the same Valkey cluster. Setting client_name sends a CLIENT SETNAME command on connection, making the connection identifiable in: - CLIENT LIST output - Monitoring dashboards (e.g., Valkey Admin) - CloudWatch metrics (ElastiCache) --- python/semantic_kernel/connectors/redis.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/python/semantic_kernel/connectors/redis.py b/python/semantic_kernel/connectors/redis.py index 575624895aca..8753745a9bdf 100644 --- a/python/semantic_kernel/connectors/redis.py +++ b/python/semantic_kernel/connectors/redis.py @@ -241,7 +241,10 @@ def __init__( definition=definition, collection_name=collection_name, embedding_generator=embedding_generator, - redis_database=Redis.from_url(redis_settings.connection_string.get_secret_value()), + redis_database=Redis.from_url( + redis_settings.connection_string.get_secret_value(), + client_name="semantic_kernel_vector_store_client", + ), prefix_collection_name_to_key_names=prefix_collection_name_to_key_names, collection_type=collection_type, **kwargs, @@ -786,7 +789,10 @@ def __init__( except ValidationError as ex: raise VectorStoreInitializationException("Failed to create Redis settings.", ex) from ex super().__init__( - redis_database=Redis.from_url(redis_settings.connection_string.get_secret_value()), + redis_database=Redis.from_url( + redis_settings.connection_string.get_secret_value(), + client_name="semantic_kernel_vector_store_client", + ), embedding_generator=embedding_generator, **kwargs, ) From a0377ec1c66024221484e1c97fbfe4e7403f7931 Mon Sep 17 00:00:00 2001 From: GitHub Copilot Date: Thu, 28 May 2026 11:28:35 -0400 Subject: [PATCH 2/2] refactor: Make Redis client_name configurable with sensible default Addresses PR feedback on issue #14038 Changes: - Added 'client_name' parameter to RedisCollection.__init__() with default - Added 'client_name' parameter to RedisStore.__init__() with default - Updated docstrings to document the new parameter - Follows the same pattern as Cosmos connector's 'application_name' parameter - Maintains backward compatibility with default value This allows callers to override the client name for their specific use case while providing a sensible default 'semantic_kernel_vector_store_client' for cases where custom naming is not required. --- python/semantic_kernel/connectors/redis.py | 31 +++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/python/semantic_kernel/connectors/redis.py b/python/semantic_kernel/connectors/redis.py index 8753745a9bdf..c0d08f6c01aa 100644 --- a/python/semantic_kernel/connectors/redis.py +++ b/python/semantic_kernel/connectors/redis.py @@ -207,6 +207,7 @@ def __init__( connection_string: str | None = None, env_file_path: str | None = None, env_file_encoding: str | None = None, + client_name: str | None = None, **kwargs: Any, ) -> None: """RedisMemoryStore is an abstracted interface to interact with a Redis node connection. @@ -214,6 +215,19 @@ def __init__( See documentation about connections: https://redis-py.readthedocs.io/en/stable/connections.html See documentation about vector attributes: https://redis.io/docs/stack/search/reference/vectors. + Args: + record_type: The type of the data model. + definition: The model fields, optional. + collection_name: The name of the collection. + embedding_generator: The embedding generator to use. + redis_database: The Redis database connection, if provided will use this instead of creating a new one. + prefix_collection_name_to_key_names: Whether to prefix the collection name to key names. + collection_type: The type of collection to use (HASHSET or JSON). + connection_string: The connection string for Redis. + env_file_path: The path to the environment file. + env_file_encoding: The encoding of the environment file. + client_name: The client name to use for the Redis connection. Defaults to + "semantic_kernel_vector_store_client". """ if redis_database: super().__init__( @@ -243,7 +257,7 @@ def __init__( embedding_generator=embedding_generator, redis_database=Redis.from_url( redis_settings.connection_string.get_secret_value(), - client_name="semantic_kernel_vector_store_client", + client_name=client_name or "semantic_kernel_vector_store_client", ), prefix_collection_name_to_key_names=prefix_collection_name_to_key_names, collection_type=collection_type, @@ -770,9 +784,20 @@ def __init__( env_file_path: str | None = None, env_file_encoding: str | None = None, redis_database: Redis | None = None, + client_name: str | None = None, **kwargs: Any, ) -> None: - """RedisMemoryStore is an abstracted interface to interact with a Redis instance.""" + """RedisMemoryStore is an abstracted interface to interact with a Redis instance. + + Args: + connection_string: The connection string for Redis. + embedding_generator: The embedding generator to use. + env_file_path: The path to the environment file. + env_file_encoding: The encoding of the environment file. + redis_database: The Redis database connection, if provided will use this instead of creating a new one. + client_name: The client name to use for the Redis connection. Defaults to + "semantic_kernel_vector_store_client". + """ if redis_database: super().__init__( redis_database=redis_database, @@ -791,7 +816,7 @@ def __init__( super().__init__( redis_database=Redis.from_url( redis_settings.connection_string.get_secret_value(), - client_name="semantic_kernel_vector_store_client", + client_name=client_name or "semantic_kernel_vector_store_client", ), embedding_generator=embedding_generator, **kwargs,