Skip to content

UserWarning: Pydantic serializer warnings when streaming with structured output #38034

@Danstiv

Description

@Danstiv

Submission checklist

  • This is a bug, not a usage question.
  • I added a clear and descriptive title that summarizes this issue.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
  • This is not related to the langchain-community package.
  • I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Package (Required)

  • langchain
  • langchain-openai
  • langchain-anthropic
  • langchain-classic
  • langchain-core
  • langchain-model-profiles
  • langchain-tests
  • langchain-text-splitters
  • langchain-chroma
  • langchain-deepseek
  • langchain-exa
  • langchain-fireworks
  • langchain-groq
  • langchain-huggingface
  • langchain-mistralai
  • langchain-nomic
  • langchain-ollama
  • langchain-openrouter
  • langchain-perplexity
  • langchain-qdrant
  • langchain-xai
  • Other / not sure / general

Related Issues / PRs

#35538

Reproduction Steps / Example Code (Python)

from langchain_openai import ChatOpenAI
from pydantic import BaseModel

llm = ChatOpenAI(model='gpt-5.4', streaming=True)

class ModelOutput(BaseModel):
    output: str


print(llm.with_structured_output(ModelOutput).invoke("What is the capital of France?"))

Error Message and Stack Trace (if applicable)

D:\temp\.venv\Lib\site-packages\pydantic\main.py:464: UserWarning: Pydantic serializer warnings:
  PydanticSerializationUnexpectedValue(Expected `none` - serialized value may not be as expected [field_name='parsed', input_value=ModelOutput(output='Paris.'), input_type=ModelOutput])
  return self.__pydantic_serializer__.to_python(
output='Paris.'

Description

Enabling streaming causes warning demonstrated in the example
It happens here


Warning when model invoked without streaming was fixed in #35543, but for streaming issue remains.

System Info

System Information

OS: Windows
OS Version: 10.0.26200
Python Version: 3.14.6 (tags/v3.14.6:c63aec6, Jun 10 2026, 10:26:10) [MSC v.1944 64 bit (AMD64)]

Package Information

langchain_core: 1.4.3
langchain: 1.3.7
langsmith: 0.8.14
langchain_openai: 1.3.0
langchain_protocol: 0.0.16
langgraph_sdk: 0.4.2

Optional packages not installed

deepagents
deepagents-cli

Other Dependencies

httpx: 0.28.1
jsonpatch: 1.33
langgraph: 1.2.4
openai: 2.41.1
orjson: 3.11.9
packaging: 26.2
pydantic: 2.13.4
pyyaml: 6.0.3
requests: 2.34.2
requests-toolbelt: 1.0.0
tenacity: 9.1.4
tiktoken: 0.13.0
typing-extensions: 4.15.0
uuid-utils: 0.16.0
websockets: 15.0.1
xxhash: 3.7.0
zstandard: 0.25.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugRelated to a bug, vulnerability, unexpected error with an existing featurecore`langchain-core` package issues & PRsexternallangchain`langchain` package issues & PRsopenai`langchain-openai` package issues & PRs

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions