[PR #6103] fix: generic type args should be serialized for de-serialization, clo… #4834

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

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

State: closed
Merged: No


  • fix(checkpoint): generic type args should be serialized for de-serialization

  • PR message*:

    • Description: when jsonplus serialize a pydantic v2 object, it simply writes type name of the object and module of the type to graph. In most cases, if the object is created from a specialized generic pydantic model, the deserialization will fail and a fallback dict object returned. The original code will try to import class GenericModel[AnotherModel] from the module, this only work if the specialized type is defined at top level of a module, I assume it is pydantic's behaviour to add identifier GenericModel[AnotherModel] to module after calling a generic pydantic model's __class_getitem__ method.

The fix code will write all generic type arguments into graph and then create these types on de-serialization.
It is compatible with data serialized by the original code and maintains the same behavior as the original code (returning a dict). closing #6102.

  • Issue: #6102
  • Dependencies: None
  • tests: added tests.test_jsonplus.test_serde_jsonplus_with_pydantic_generic
**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/6103 **State:** closed **Merged:** No --- - fix(checkpoint): generic type args should be serialized for de-serialization - *PR message**: - **Description:** when jsonplus serialize a pydantic v2 object, it simply writes type name of the object and module of the type to graph. In most cases, if the object is created from a specialized generic pydantic model, the deserialization will fail and a fallback dict object returned. The original code will try to import class `GenericModel[AnotherModel]` from the module, this only work if the specialized type is defined at top level of a module, I assume it is pydantic's behaviour to add identifier `GenericModel[AnotherModel]` to module after calling a generic pydantic model's `__class_getitem__` method. The fix code will write all generic type arguments into graph and then create these types on de-serialization. It is compatible with data serialized by the original code and maintains the same behavior as the original code (returning a dict). closing #6102. - **Issue:** #6102 - **Dependencies:** None - **tests:** added `tests.test_jsonplus.test_serde_jsonplus_with_pydantic_generic`
yindo added the pull-request label 2026-02-20 17:50:49 -05:00
yindo closed this issue 2026-02-20 17:50:49 -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#4834