{"record":{"id":"6cd9af69c071d96a","repo":"microsoft/semantic-kernel","slug":"sequence-operations-in-filter-expressions-exceed-t","errorCode":null,"errorMessage":"Sequence operations in filter expressions exceed the maximum allowed size.","messagePattern":"Sequence operations in filter expressions exceed the maximum allowed size\\.","errorType":"exception","errorClass":"VectorStoreOperationException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/in_memory.py","lineNumber":402,"sourceCode":"            )\n        return operation(left, right)\n\n    def _ensure_literal_collection_size(self, size: int) -> None:\n        \"\"\"Reject excessively large literal collections.\"\"\"\n        if size > self._max_literal_collection_size:\n            raise VectorStoreOperationException(\n                \"Collection literals in filter expressions exceed the maximum allowed size.\"\n            )\n\n    def _ensure_sequence_result_size(\n        self,\n        left: str | list[Any] | tuple[Any, ...],\n        right: str | list[Any] | tuple[Any, ...],\n        operation: Callable[[Any, Any], Any],\n    ) -> Any:\n        \"\"\"Reject oversized sequence concatenation results.\"\"\"\n        if len(left) + len(right) > self._max_sequence_repeat_size:\n            raise VectorStoreOperationException(\n                \"Sequence operations in filter expressions exceed the maximum allowed size.\"\n            )\n        return operation(left, right)\n\n    def _evaluate_optional(self, node: ast.AST | None, context: Mapping[str, Any]) -> Any:\n        \"\"\"Evaluate an optional AST node.\"\"\"\n        return self.evaluate(node, context) if node is not None else None\n\n\nclass InMemoryCollection(\n    VectorStoreCollection[TKey, TModel],\n    VectorSearch[TKey, TModel],\n    Generic[TKey, TModel],\n):\n    \"\"\"In Memory Collection.\"\"\"\n\n    inner_storage: dict[TKey, AttributeDict] = Field(default_factory=dict)\n    supported_key_types: ClassVar[set[str] | None] = {\"str\", \"int\", \"float\"}","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/in_memory.py#L384-L420","documentation":"Thrown by _ensure_sequence_result_size (in_memory.py:401-403) when concatenating two sequences whose combined length exceeds max_filter_sequence_repeat_size (default 1024). This is a runtime check on actual value lengths (len(left)+len(right)) and is not fully duplicated at parse time, so concatenating long field values can trigger it.","triggerScenarios":"A filter like `lambda x: x.desc + x.notes == 'target'` where both fields are long strings/lists whose combined length exceeds 1024.","commonSituations":"Concatenating two text/list fields in a filter; storing long descriptions and joining them for comparison.","solutions":["Avoid concatenating long fields inside filters; compare fields separately or precompute a combined field at write time.","Raise max_filter_sequence_repeat_size if legitimate concatenation needs more headroom.","Use startswith()/endswith() (allowlisted methods) instead of full concatenation when possible."],"exampleFix":"# before\nVectorSearchOptions(filter=\"lambda x: x.desc + x.notes == 'target'\")  # may exceed 1024\n# after\nVectorSearchOptions(filter=\"lambda x: x.combined == 'target'\")  # precompute a 'combined' field on upsert","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    results = await collection.search(search_type=SearchType.VECTOR, options=opts)\nexcept VectorStoreOperationException as e:\n    logger.warning(\"filter rejected: %s\", e.__cause__ or e)\n    results = None","preventionTips":["Do not concatenate long fields in filters.","Store derived/combined values as their own fields when you write records."],"tags":["filter","in-memory","resource-limits","semantic-kernel","evaluation"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}