Repository navigation
Description
Observed Behavior
A valid Pydantic vector record using Field(validation_alias=AliasChoices("record_id", "document_id")) is accepted by model construction and InMemoryCollection.upsert(), but reading the returned key raises a missing-field ValidationError for record_id.
The default vector-model decoder builds its validation mapping with logical field names when the validation alias is not a string. Pydantic rejects the resulting id input for this alias-only field.
Expected Behavior
A record accepted by the default vector model and successfully upserted should round-trip through get(). If this alias shape is intentionally unsupported, rejection at registration would make the contract explicit instead of failing after a successful write. Please confirm the intended AliasChoices support boundary and preferred direction before implementation.
Steps to Reproduce
- Install core from main
098214127152b3bf26159c3e17ac0a019aa025b6in an isolated environment. - Run the following offline script. No model, credentials, embeddings service or database server is used.
- Observe successful upsert followed by a missing-field validation error.
Minimal Reproduction
import asyncio
from typing import Annotated
from pydantic import AliasChoices, BaseModel, Field
from agent_framework import InMemoryCollection, VectorStoreField, vectorstoremodel
@vectorstoremodel(collection_name="alias-choice-repro")
class Record(BaseModel):
id: Annotated[str, VectorStoreField("key")] = Field(
validation_alias=AliasChoices("record_id", "document_id")
)
text: Annotated[str, VectorStoreField("data")]
vector: Annotated[list[float], VectorStoreField("vector", dimensions=2)] = Field(default_factory=list)
async def main():
collection = InMemoryCollection(Record)
await collection.ensure_collection_exists()
record = Record(record_id="one", text="plain sample", vector=[0.25, 0.75])
keys = await collection.upsert([record], generate_vectors=False)
print("upsert:", keys)
try:
print("get:", await collection.get(keys, include_vectors=True))
except Exception as error:
print(type(error).__name__ + ":", error)
asyncio.run(main())Error Messages and Stack Traces
upsert: ['one']
ValidationError: 1 validation error for Record
record_id
Field required [type=missing, input_value={'id': 'one', ...}, input_type=dict]
Package Versions
agent-framework-core 1.25.0, installed editable from the exact source above; Pydantic 2.14.3; msgspec 0.22.0.
Python Version
Python 3.14.3
Operating System
Windows
Regression
Unknown.
Additional Context
Controls using a dataclass and a Pydantic string alias both round-trip with the same fields, data, source and environment. The AliasChoices case fails through public CRUD, without invoking the decoder directly.
The same offline reproduction and both controls were rerun on current main e59c25956063af1d2dde1df66415957d4938b3de with the same results. _vectors.py is unchanged between the initial revision and this recheck.
All-state issue and PR searches for AliasChoices and vector/validation_alias found no matching vector decoder report or implementation. Related PR #9250 changes nested registered-value restoration in _sessions.py only; Milvus PR #9346 adds a connector and does not change the core vector decoder. Existing issues #9060 (native UUID lookup/delete keys), #8625 (null auto-generated keys in upsert tools), and #1188 (vector connector roadmap) concern different behavior.
This report requests agreement on the problem and direction. No framework implementation or fix PR has been prepared. Any proposed support must preserve the declared Pydantic dependency range.
AI assistance: a coding assistant prepared and executed the offline reproductions and source analysis. The human submitter has personally verified the reported behavior and confirmed the authenticity of the reproduction details.
Acknowledgements
- I searched existing issues and did not find a duplicate.
- I personally verified this behavior and the reproduction details are authentic.
- I will wait for explicit maintainer agreement before starting implementation of a non-trivial change.
Metadata
Metadata
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
github-actions commentedon Nov 10, 2026
Reproduced on current main (
e59c259) using an independently written offline script based on the described behavior:upsertreturns['one'], thenget()raisesValidationError ... record_id Field required. The decoder inpython/packages/core/agent_framework/_vectors.py(~L580) only uses string aliases, so anAliasChoicesfield is fed the logical nameid.Support boundary: unclear. I found no maintained doc or decision record covering
AliasChoiceson vector models, so whether to support it or reject it at registration is a maintainer decision. This does not imply acceptance or priority.Run: https://github.com/microsoft/agent-framework/actions/runs/42821678220
eavanvalkenburg commentedon Nov 11, 2026
I'm a bit unsure of the scenario here, we already support a
storage_namein case you want to have different names in the model and the storage, so you could do:which should work, will that not give you the same?
FOWEPJF255 commentedon Nov 12, 2026
Thanks for the example. The scenario is accepting multiple external payload names for the same Pydantic field, rather than choosing a different database column name. For example, both
record_idanddocument_idpayloads construct the original model successfully; the failure happens when decoding the stored record.Rechecking on main
b230c8c5e2d8e206c4f293d16b7ba771e584470a, the proposed model withrecord_id,storage_name="id", andvalidation_alias=AliasChoices("document_id")still fails atget(). Construction and upsert succeed, but validation requiresdocument_idwhile the decoder suppliesrecord_id.Using the
Recordclass from your comment:The offline comparisons were:
record_idwithstorage_name="id", no validation aliasvalidation_alias="document_id"AliasChoices("document_id")document_idAliasChoices("record_id", "document_id"), either accepted input namerecord_idThe environment was Windows, Python 3.14.3, Pydantic 2.14.3, and msgspec 0.22.0, using the existing editable core installation with source updated to that exact main revision. No embedding generation, external database, or model service was involved.
Could you confirm whether this alias shape should round-trip, or whether unsupported alias shapes should instead be rejected when registering the vector model? That would establish the intended contract before a fix is prepared.
AI assistance: a coding assistant prepared and executed these additional offline comparisons and helped draft this reply.