langchain - 💡(How to fix) Fix UserWarning: Pydantic serializer warnings:

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

UserWarning: Pydantic serializer warnings: PydanticSerializationUnexpectedValue(Expected none - serialized value may not be as expected [field_name='parsed', input_value=IntentRecognitionOutput(c...xxxx》'), input_type=IntentRecognitionOutput]) return self.pydantic_serializer.to_python(

Error Message

Error Message and Stack Trace (if applicable)

Root Cause

UserWarning: Pydantic serializer warnings: PydanticSerializationUnexpectedValue(Expected none - serialized value may not be as expected [field_name='parsed', input_value=IntentRecognitionOutput(c...xxxx》'), input_type=IntentRecognitionOutput]) return self.pydantic_serializer.to_python(

Fix Action

Fix / Workaround

  • 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.

Other Dependencies

aiohttp: 3.13.5 docling: 2.95.0 httpx: 0.28.1 httpx-sse: 0.4.3 jsonpatch: 1.33 langgraph: 1.2.2 numpy: 2.3.5 openai: 2.38.0 opentelemetry-api: 1.42.1 opentelemetry-exporter-otlp-proto-http: 1.42.1 opentelemetry-sdk: 1.42.1 orjson: 3.11.9 packaging: 26.2 pydantic: 2.13.4 pydantic-settings: 2.14.1 pymilvus: 2.6.14 pytest: 9.0.3 pyyaml: 6.0.2 requests: 2.34.2 requests-toolbelt: 1.0.0 rich: 15.0.0 sqlalchemy: 2.0.50 tenacity: 9.1.4 tiktoken: 0.13.0 typing-extensions: 4.15.0 unstructured: 0.21.5 unstructured-client: 0.44.0 uuid-utils: 0.16.0 websockets: 16.0 wrapt: 1.17.3 xxhash: 3.7.0 zstandard: 0.25.0

Code Example

intent_recognition_output = (
            get_llm()
            .with_structured_output(IntentRecognitionOutput, include_raw=False)
            .invoke([
                SystemMessage(content=sys_prompt)
            ])
        )

class IntentRecognitionOutput(BaseModel):
    classification: str

    model_config = ConfigDict(
        extra="ignore"
    )

from typing import Optional

from langchain_openai import ChatOpenAI

from app.config import settings
from app.infra.logger.logger import log

_llm: ChatOpenAI | None = None


def get_llm() -> ChatOpenAI:
    """
    Get the ChatOpenAI LLM instance.

    Returns:
        BaseChatModel: Configured LLM instance
    """
    global _llm

    if _llm is None:
        _llm = ChatOpenAI(
            model=settings.LLM_MODEL,
            base_url=settings.LLM_BASE_URL,
            api_key=settings.LLM_API_KEY,
        )

    return _llm

---
RAW_BUFFERClick to expand / collapse

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

No response

Reproduction Steps / Example Code (Python)

intent_recognition_output = (
            get_llm()
            .with_structured_output(IntentRecognitionOutput, include_raw=False)
            .invoke([
                SystemMessage(content=sys_prompt)
            ])
        )

class IntentRecognitionOutput(BaseModel):
    classification: str

    model_config = ConfigDict(
        extra="ignore"
    )

from typing import Optional

from langchain_openai import ChatOpenAI

from app.config import settings
from app.infra.logger.logger import log

_llm: ChatOpenAI | None = None


def get_llm() -> ChatOpenAI:
    """
    Get the ChatOpenAI LLM instance.

    Returns:
        BaseChatModel: Configured LLM instance
    """
    global _llm

    if _llm is None:
        _llm = ChatOpenAI(
            model=settings.LLM_MODEL,
            base_url=settings.LLM_BASE_URL,
            api_key=settings.LLM_API_KEY,
        )

    return _llm

Error Message and Stack Trace (if applicable)

Description

UserWarning: Pydantic serializer warnings: PydanticSerializationUnexpectedValue(Expected none - serialized value may not be as expected [field_name='parsed', input_value=IntentRecognitionOutput(c...xxxx》'), input_type=IntentRecognitionOutput]) return self.pydantic_serializer.to_python(

System Info

System Information

OS: Darwin OS Version: Darwin Kernel Version 25.5.0: Mon Apr 27 20:41:26 PDT 2026; root:xnu-12377.121.6~2/RELEASE_ARM64_T8132 Python Version: 3.12.13 (main, Apr 7 2026, 21:09:58) [Clang 22.1.1 ]

Package Information

langchain_core: 1.4.0 langchain: 1.3.2 langchain_community: 0.4.2 langsmith: 0.8.5 langchain_classic: 1.0.7 langchain_docling: 2.0.0 langchain_milvus: 0.3.3 langchain_openai: 1.2.2 langchain_protocol: 0.0.15 langchain_text_splitters: 1.1.2 langchain_unstructured: 1.0.1 langgraph_sdk: 0.3.15

Optional packages not installed

deepagents deepagents-cli

Other Dependencies

aiohttp: 3.13.5 docling: 2.95.0 httpx: 0.28.1 httpx-sse: 0.4.3 jsonpatch: 1.33 langgraph: 1.2.2 numpy: 2.3.5 openai: 2.38.0 opentelemetry-api: 1.42.1 opentelemetry-exporter-otlp-proto-http: 1.42.1 opentelemetry-sdk: 1.42.1 orjson: 3.11.9 packaging: 26.2 pydantic: 2.13.4 pydantic-settings: 2.14.1 pymilvus: 2.6.14 pytest: 9.0.3 pyyaml: 6.0.2 requests: 2.34.2 requests-toolbelt: 1.0.0 rich: 15.0.0 sqlalchemy: 2.0.50 tenacity: 9.1.4 tiktoken: 0.13.0 typing-extensions: 4.15.0 unstructured: 0.21.5 unstructured-client: 0.44.0 uuid-utils: 0.16.0 websockets: 16.0 wrapt: 1.17.3 xxhash: 3.7.0 zstandard: 0.25.0

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING