{"record":{"id":"85bf2d29fb500d5d","repo":"microsoft/autogen","slug":"to-use-redis-memory-redisvl-must-be-installed-run","errorCode":null,"errorMessage":"To use Redis Memory RedisVL must be installed. Run `pip install autogen-ext[redisvl]`","messagePattern":"To use Redis Memory RedisVL must be installed\\. Run `pip install autogen-ext\\[redisvl\\]`","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/memory/redis/_redis_memory.py","lineNumber":18,"sourceCode":"import logging\nfrom typing import Any, List, Literal\n\nfrom autogen_core import CancellationToken, Component\nfrom autogen_core.memory import Memory, MemoryContent, MemoryMimeType, MemoryQueryResult, UpdateContextResult\nfrom autogen_core.model_context import ChatCompletionContext\nfrom autogen_core.models import SystemMessage\nfrom pydantic import BaseModel, Field\n\nlogger = logging.getLogger(__name__)\n\ntry:\n    from redis import Redis\n    from redisvl.extensions.message_history import MessageHistory, SemanticMessageHistory\n    from redisvl.utils.utils import deserialize, serialize\n    from redisvl.utils.vectorize import HFTextVectorizer\nexcept ImportError as e:\n    raise ImportError(\"To use Redis Memory RedisVL must be installed. Run `pip install autogen-ext[redisvl]`\") from e\n\n\nclass RedisMemoryConfig(BaseModel):\n    \"\"\"\n    Configuration for Redis-based vector memory.\n\n    This class defines the configuration options for using Redis as a vector memory store,\n    supporting semantic memory. It allows customization of the Redis connection, index settings,\n    similarity search parameters, and embedding model.\n    \"\"\"\n\n    redis_url: str = Field(default=\"redis://localhost:6379\", description=\"url of the Redis instance\")\n    index_name: str = Field(default=\"chat_history\", description=\"Name of the Redis collection\")\n    prefix: str = Field(default=\"memory\", description=\"prefix of the Redis collection\")\n    sequential: bool = Field(\n        default=False, description=\"ignore semantic similarity and simply return memories in sequential order\"\n    )\n    distance_metric: Literal[\"cosine\", \"ip\", \"l2\"] = \"cosine\"","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/memory/redis/_redis_memory.py#L1-L36","documentation":"RedisMemory depends on the redisvl package (plus redis), which is an optional dependency shipped as the autogen-ext[redisvl] extra. Importing autogen_ext.memory.redis without it raises ImportError with the exact pip command needed. This is the standard optional-dependency gate pattern used across autogen-ext.","triggerScenarios":"import autogen_ext.memory.redis (or any module transitively importing it) without redisvl installed; a fresh environment where autogen-ext was installed without extras; partial installs where redis is present but redisvl is not.","commonSituations":"New project scaffolding that copies a RedisMemory example; Docker images built from a slim requirements list without the extra; CI cache serving an environment created before RedisMemory was added to the codebase.","solutions":["Install the extra: pip install autogen-ext[redisvl].","Or install the dependency directly: pip install redisvl.","Add the extra to requirements.txt/pyproject so environments are reproducible."],"exampleFix":"# before\n# ImportError: To use Redis Memory RedisVL must be installed...\nfrom autogen_ext.memory.redis import RedisMemory\n\n# after (shell)\n# pip install autogen-ext[redisvl]\nfrom autogen_ext.memory.redis import RedisMemory","handlingStrategy":"try-catch","validationCode":"try:\n    import redisvl  # noqa: F401\n    HAVE_REDISVL = True\nexcept ImportError:\n    HAVE_REDISVL = False\n\nif not HAVE_REDISVL:\n    raise SystemExit('Run: pip install autogen-ext[redisvl]')","typeGuard":null,"tryCatchPattern":"try:\n    from autogen_ext.memory.redis import RedisMemory\nexcept ImportError as e:\n    if 'redisvl' in str(e):\n        LOG.error('missing optional dep; run pip install autogen-ext[redisvl]')\n        raise SystemExit(2) from e\n    raise","preventionTips":["Pin autogen-ext[redisvl] in requirements/pyproject","Fail at process start with the install hint instead of mid-run","Include extras in Docker/CI environment definitions"],"tags":["redis","redisvl","dependency","import-error"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}