Skip to content

[Bug]: UserWarning: Pydantic serializer warnings: PydanticSerializationUnexpectedValue(Expected 9 fields but got 6: ... #11759

@njbrake

Description

@njbrake

What happened?

When upgrading from LiteLLM 1.72.4 to 1.72.6, I now get a pydantic Serialization warning about unexpected values.

It's triggered by this code:

Image

I'm using model_id="gpt-4.1-mini" and the acompletion API

Found while working on mozilla-ai/any-agent#370

https://github.com/mozilla-ai/any-llm

Relevant log output

/Users/nbrake/scm/any-agent/.venv/lib/python3.13/site-packages/pydantic/main.py:464: UserWarning: Pydantic serializer warnings:
  PydanticSerializationUnexpectedValue(Expected 9 fields but got 6: Expected `Message` - serialized value may not be as expected [input_value=Message(content=None, rol...: None}, annotations=[]), input_type=Message])
  PydanticSerializationUnexpectedValue(Expected `StreamingChoices` - serialized value may not be as expected [input_value=Choices(finish_reason='to...ider_specific_fields={}), input_type=Choices])
  return self.__pydantic_serializer__.to_python(

Are you a ML Ops Team?

No

What LiteLLM version are you on ?

1.72.6

Twitter / LinkedIn details

https://www.linkedin.com/in/njbrake/

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions