microsoft/semantic-kernel · error · VectorStoreModelValidationError
Field name '{IN_MEMORY_SCORE_KEY}' is reserved for internal
Error message
Field name '{IN_MEMORY_SCORE_KEY}' is reserved for internal use. What it means
Thrown by _validate_data_model (in_memory.py:613-614) as VectorStoreModelValidationError when the data model defines a field named 'in_memory_search_score' (IN_MEMORY_SCORE_KEY). The collection writes vector search scores into each result record under that key, so a user field with the same name would collide and corrupt either the score or the data.
Source
Thrown at python/semantic_kernel/connectors/in_memory.py:614
> - `max_filter_literal_collection_size=256`
> - `max_filter_sequence_repeat_size=1024`
> You can override these limits by passing them through `kwargs` or by setting them on the collection
> instance after initialization.
"""
super().__init__(
record_type=record_type,
definition=definition,
collection_name=collection_name,
embedding_generator=embedding_generator,
**kwargs,
)
def _validate_data_model(self):
"""Check if the In Memory Score key is not used."""
super()._validate_data_model()
if IN_MEMORY_SCORE_KEY in self.definition.names:
raise VectorStoreModelValidationError(f"Field name '{IN_MEMORY_SCORE_KEY}' is reserved for internal use.")
@override
async def _inner_delete(self, keys: Sequence[TKey], **kwargs: Any) -> None:
for key in keys:
self.inner_storage.pop(key, None)
@override
async def _inner_get(
self, keys: Sequence[TKey] | None = None, options: GetFilteredRecordOptions | None = None, **kwargs: Any
) -> Any | OneOrMany[TModel] | None:
if not keys:
if options is not None:
raise NotImplementedError("Get without keys is not yet implemented.")
return None
return [self.inner_storage[key] for key in keys if key in self.inner_storage]
@override
async def _inner_upsert(self, records: Sequence[Any], **kwargs: Any) -> Sequence[TKey]:View on GitHub (pinned to c028a0c7dc)
Solutions
- Rename the field to anything other than 'in_memory_search_score'.
- If you need a score field, name it e.g. 'score', 'relevance', or 'my_score'.
Example fix
# before
class Rec(VectorStoreRecord):
id: str
in_memory_search_score: float # reserved!
# after
class Rec(VectorStoreRecord):
id: str
relevance_score: float Defensive patterns
Strategy: validation
Validate before calling
RESERVED = 'in_memory_search_score'
def check_field_names(names: list[str]) -> None:
if RESERVED in names:
raise ValueError(f"field name '{RESERVED}' is reserved by InMemoryCollection") Type guard
from semantic_kernel.connectors.in_memory import IN_MEMORY_SCORE_KEY
def is_safe_field_name(name: str) -> bool:
return name != IN_MEMORY_SCORE_KEY Try / catch
try:
collection = store.get_collection(record_type=Rec, definition=definition)
await collection.create_collection()
except VectorStoreModelValidationError as e:
# rename the colliding field and recreate the definition
... Prevention
- Reserve 'in_memory_search_score' as off-limits when designing in-memory models.
- Validate field names against IN_MEMORY_SCORE_KEY before creating a collection.
When it happens
Trigger: Defining a VectorStoreRecordDefinition or pydantic model with a field/storage_name equal to 'in_memory_search_score' and creating/getting an InMemoryCollection for it; the validation runs during collection initialization.
Common situations: Choosing a generic score field name; copying a model schema from another store without checking reserved names; version upgrades that introduce the reserved key.
Related errors
- Vector field '{options.vector_property_name}' not found in t
- Chroma only supports one vector field, but {len(self.definit
- Attribute '{node.func.attr}' is not callable in filter expre
- Get without keys is not yet implemented.
- Filter string must be a lambda expression, e.g. 'lambda x: x
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/2fcab7d23742d875.
Report an issue: GitHub.