[PR #6640] feat(langgraph): Update state coercion for pydantic models #5184

Open
opened 2026-02-20 17:51:21 -05:00 by yindo · 0 comments
Owner

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

State: open
Merged: No


Description:

Add fallback to model_construct() in _coerce_state when Pydantic validation fails, aligning Pydantic state coercion behavior with TypedDict's lenient parsing.
This enables Pydantic state schema evolution—adding new fields with defaults no longer breaks existing checkpoints. When validation fails (e.g., missing field added in new schema version), the function falls back to model_construct()which skips validation, similar to how TypedDict passes dicts as-is without validation.
Issue: N/A
Dependencies: None
Twitter handle: N/A

**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/6640 **State:** open **Merged:** No --- ## Description: Add fallback to `model_construct()` in _coerce_state when Pydantic validation fails, aligning Pydantic state coercion behavior with TypedDict's lenient parsing. This enables Pydantic state schema evolution—adding new fields with defaults no longer breaks existing checkpoints. When validation fails (e.g., missing field added in new schema version), the function falls back to `model_construct()`which skips validation, similar to how TypedDict passes dicts as-is without validation. Issue: N/A Dependencies: None Twitter handle: N/A
yindo added the pull-request label 2026-02-20 17:51:21 -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#5184