microsoft/semantic-kernel · error · VectorStoreOperationException
Sequence operations in filter expressions exceed the maximum
Error message
Sequence operations in filter expressions exceed the maximum allowed size.
What it means
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.
Source
Thrown at python/semantic_kernel/connectors/in_memory.py:402
)
return operation(left, right)
def _ensure_literal_collection_size(self, size: int) -> None:
"""Reject excessively large literal collections."""
if size > self._max_literal_collection_size:
raise VectorStoreOperationException(
"Collection literals in filter expressions exceed the maximum allowed size."
)
def _ensure_sequence_result_size(
self,
left: str | list[Any] | tuple[Any, ...],
right: str | list[Any] | tuple[Any, ...],
operation: Callable[[Any, Any], Any],
) -> Any:
"""Reject oversized sequence concatenation results."""
if len(left) + len(right) > self._max_sequence_repeat_size:
raise VectorStoreOperationException(
"Sequence operations in filter expressions exceed the maximum allowed size."
)
return operation(left, right)
def _evaluate_optional(self, node: ast.AST | None, context: Mapping[str, Any]) -> Any:
"""Evaluate an optional AST node."""
return self.evaluate(node, context) if node is not None else None
class InMemoryCollection(
VectorStoreCollection[TKey, TModel],
VectorSearch[TKey, TModel],
Generic[TKey, TModel],
):
"""In Memory Collection."""
inner_storage: dict[TKey, AttributeDict] = Field(default_factory=dict)
supported_key_types: ClassVar[set[str] | None] = {"str", "int", "float"}View on GitHub (pinned to c028a0c7dc)
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.
Example fix
# before VectorSearchOptions(filter="lambda x: x.desc + x.notes == 'target'") # may exceed 1024 # after VectorSearchOptions(filter="lambda x: x.combined == 'target'") # precompute a 'combined' field on upsert
Defensive patterns
Strategy: try-catch
Try / catch
try:
results = await collection.search(search_type=SearchType.VECTOR, options=opts)
except VectorStoreOperationException as e:
logger.warning("filter rejected: %s", e.__cause__ or e)
results = None Prevention
- Do not concatenate long fields in filters.
- Store derived/combined values as their own fields when you write records.
When it happens
Trigger: A filter like `lambda x: x.desc + x.notes == 'target'` where both fields are long strings/lists whose combined length exceeds 1024.
Common situations: Concatenating two text/list fields in a filter; storing long descriptions and joining them for comparison.
Related errors
- Sequence repetition in filter expressions exceeds the maximu
- Collection literals in filter expressions exceed the maximum
- Attribute '{node.func.attr}' is not callable in filter expre
- Call target node type '{type(node.func).__name__}' is not al
- Comparison operator '{type(operator_node).__name__}' is not
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/6cd9af69c071d96a.
Report an issue: GitHub.