{"record":{"id":"cc9d273469f0283e","repo":"microsoft/autogen","slug":"non-sequential-queries-cannot-be-run-with-an-under","errorCode":null,"errorMessage":"Non-sequential queries cannot be run with an underlying sequential RedisMemory. Set sequential=False in RedisMemoryConfig to enable semantic memory querying.","messagePattern":"Non-sequential queries cannot be run with an underlying sequential RedisMemory\\. Set sequential=False in RedisMemoryConfig to enable semantic memory querying\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/memory/redis/_redis_memory.py","lineNumber":298,"sourceCode":"                in the RedisMemoryConfig. If a MemoryContent object is passed, the content field\n                of this object is extracted and a vector embedding is created from it with the\n                model specified in the RedisMemoryConfig.\n            cancellation_token (CancellationToken): Token passed to cease operation. Not used.\n\n        Returns:\n            memoryQueryResult: Object containing memories relevant to the provided query.\n        \"\"\"\n        top_k = kwargs.pop(\"top_k\", self.config.top_k)\n        distance_threshold = kwargs.pop(\"distance_threshold\", self.config.distance_threshold)\n\n        # return empty results for empty/whitespace queries\n        if isinstance(query, str) and not query.strip():\n            return MemoryQueryResult(results=[])\n\n        # if sequential memory is requested skip prompt creation\n        sequential = bool(kwargs.pop(\"sequential\", self.config.sequential))\n        if self.config.sequential and not sequential:\n            raise ValueError(\n                \"Non-sequential queries cannot be run with an underlying sequential RedisMemory. Set sequential=False in RedisMemoryConfig to enable semantic memory querying.\"\n            )\n        elif sequential or self.config.sequential:\n            results = self.message_history.get_recent(\n                top_k=top_k,\n                raw=False,\n            )\n        else:\n            # get the query string, or raise an error for unsupported MemoryContent types\n            if isinstance(query, str):\n                prompt = query\n            elif isinstance(query, MemoryContent):\n                if query.mime_type in (MemoryMimeType.TEXT, MemoryMimeType.MARKDOWN):\n                    prompt = str(query.content)\n                elif query.mime_type == MemoryMimeType.JSON:\n                    prompt = serialize(query.content)\n                else:\n                    raise NotImplementedError(","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/memory/redis/_redis_memory.py#L280-L316","documentation":"When RedisMemory is configured with sequential=True, it is backed by plain MessageHistory (ordered, no embeddings). Calling query() with sequential=False (per-call override) would require semantic vector search that the underlying store cannot perform, so it raises ValueError telling you to set sequential=False in the config for semantic queries.","triggerScenarios":"RedisMemoryConfig(sequential=True) then await memory.query(text, sequential=False); passing sequential=False via kwargs at query time; toggling per-call sequential on a sequentially configured memory.","commonSituations":"Reusing one memory instance for both chronological recall and semantic search; copying per-call overrides from an example that used a semantic config; misunderstanding that sequential mode cannot be downgraded per call (only non-sequential can be upgraded).","solutions":["If you need semantic (vector) queries, construct RedisMemory with RedisMemoryConfig(sequential=False) — note the reverse direction (query sequential=True on a semantic config) IS allowed.","If chronological recall is what you want, drop the sequential=False kwarg from the query call.","Use two memory instances (one sequential, one semantic) if both behaviors are needed."],"exampleFix":"# before\nconfig = RedisMemoryConfig(sequential=True)\nmemory = RedisMemory(config=config)\nawait memory.query('find notes', sequential=False)  # ValueError\n\n# after\nconfig = RedisMemoryConfig(sequential=False)\nmemory = RedisMemory(config=config)\nawait memory.query('find notes')  # semantic search","handlingStrategy":"validation","validationCode":"async def semantic_query(memory, text, **kw):\n    if memory.config.sequential:\n        raise ValueError('this memory is sequential-only; use a sequential=False config for semantic search')\n    return await memory.query(text, **kw)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Decide sequential vs semantic once at config time, not per call","Do not pass sequential=False overrides to a sequential-configured memory","Use separate instances for chronological and semantic recall"],"tags":["redis","memory","configuration","semantic-search"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}