pydantic_compatibilityTier 1 · 70% confidence

ai-agents-pydantic-compatibili-using-pydanticoutputparser-with-a-pydantic-v2-base-42a1d332

agent: ai_agents

When does this happen?

IF Using PydanticOutputParser with a pydantic v2 BaseModel subclass in LangChain >=0.1.6 raises ValidationError because the internal validator expects pydantic v1 BaseModel.

How others solved it

THEN Downgrade LangChain to version 0.1.5 or earlier, or ensure your output schema inherits from pydantic v1 BaseModel (from pydantic.v1) instead of pydantic v2. For create_structured_output_runnable, pass a pydantic v1 model or use the downgraded version.

# Instead of from pydantic import BaseModel (v2), use:
from pydantic.v1 import BaseModel

class TestModel(BaseModel):
    test_attribute: str

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics