[PR #4363] Use model_validate if needed #3783

Closed
opened 2026-02-20 17:49:09 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langchain-ai/langgraph/pull/4363

State: closed
Merged: Yes


If the state schema uses validators, skip the model construct optimization.

For context, pydantic state can be significantly slower to run than typed dict and dataclass states due to the full recursive validation.

We have some optimizations to reduce the impact of this (using cached validators with model_construct), but this doesn't handle things like field_validator.

We prefer correctness over performance, obviously.

Resolves: https://github.com/langchain-ai/langgraph/issues/4074

**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/4363 **State:** closed **Merged:** Yes --- If the state schema uses validators, skip the model construct optimization. For context, pydantic state can be significantly slower to run than typed dict and dataclass states due to the full recursive validation. We have some optimizations to reduce the impact of this (using cached validators with model_construct), but this doesn't handle things like field_validator. We prefer correctness over performance, obviously. Resolves: https://github.com/langchain-ai/langgraph/issues/4074
yindo added the pull-request label 2026-02-20 17:49:09 -05:00
yindo closed this issue 2026-02-20 17:49:09 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#3783