langgraph-checkpoint-postgres fails to persist state fields with Pydantic model types #343

Closed
opened 2026-02-20 17:37:42 -05:00 by yindo · 2 comments
Owner

Originally created by @shivangag on GitHub (Dec 6, 2024).

Checked other resources

  • This is a bug, not a usage question. For questions, please use GitHub Discussions.
  • I added a clear and detailed title that summarizes the issue.
  • I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example).
  • I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue.

Example Code

class XOutput(BaseModel):
    x: str = Field(description="Some variable x")
    y: str = Field(description="Some variable y")


class AgentState(BaseModel):
    class Config:
        arbitrary_types_allowed = True

    tool_caller: Optional[str] = Field(default=None)
    messages: Annotated[List[BaseMessage], add_messages] = Field(default_factory=list)
    output: Optional[XOutput]

Error Message and Stack Trace (if applicable)

No response

Description

I'm using an AgentState similar to the example code. While streaming the graph with stream mode set to "debug" and using the postgres-checkpointer, I correctly get the value of 'output' state field.
But when running app.get_state_history(config), with the correct config set, I'm getting null value for output. other fields with str types are returned correctly though.
Do langgraph-checkpoint-postgres not support fields with pydantic model type?

System Info

System Information

OS: Darwin
OS Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:16:46 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T8112
Python Version: 3.11.9 (main, Aug 12 2024, 16:41:06) [Clang 15.0.0 (clang-1500.3.9.4)]

Package Information

langchain_core: 0.3.21
langchain: 0.3.9
langchain_community: 0.3.8
langsmith: 0.1.142
langchain_anthropic: 0.3.0
langchain_aws: 0.2.7
langchain_google_genai: 2.0.6
langchain_google_vertexai: 2.0.8
langchain_groq: 0.2.1
langchain_openai: 0.2.10
langchain_text_splitters: 0.3.2
langgraph_sdk: 0.1.35

Optional packages not installed

langserve

Other Dependencies

aiohttp: 3.10.3
anthropic: 0.39.0
anthropic[vertexai]: Installed. No version info available.
async-timeout: Installed. No version info available.
boto3: 1.34.158
dataclasses-json: 0.6.7
defusedxml: 0.7.1
filetype: 1.2.0
google-cloud-aiplatform: 1.72.0
google-cloud-storage: 2.18.2
google-generativeai: 0.8.3
groq: 0.9.0
httpx: 0.27.0
httpx-sse: 0.4.0
jsonpatch: 1.33
langchain-mistralai: Installed. No version info available.
numpy: 1.26.4
openai: 1.54.4
orjson: 3.10.7
packaging: 24.1
pydantic: 2.9.2
pydantic-settings: 2.6.1
PyYAML: 6.0.2
requests: 2.32.3
requests-toolbelt: 1.0.0
SQLAlchemy: 2.0.32
tenacity: 8.5.0
tiktoken: 0.7.0
typing-extensions: 4.12.2

Originally created by @shivangag on GitHub (Dec 6, 2024). ### Checked other resources - [X] This is a bug, not a usage question. For questions, please use GitHub Discussions. - [X] I added a clear and detailed title that summarizes the issue. - [X] I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example). - [X] I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue. ### Example Code ```python class XOutput(BaseModel): x: str = Field(description="Some variable x") y: str = Field(description="Some variable y") class AgentState(BaseModel): class Config: arbitrary_types_allowed = True tool_caller: Optional[str] = Field(default=None) messages: Annotated[List[BaseMessage], add_messages] = Field(default_factory=list) output: Optional[XOutput] ``` ### Error Message and Stack Trace (if applicable) _No response_ ### Description I'm using an AgentState similar to the example code. While streaming the graph with stream mode set to "debug" and using the postgres-checkpointer, I correctly get the value of 'output' state field. But when running app.get_state_history(config), with the correct config set, I'm getting null value for output. other fields with str types are returned correctly though. Do langgraph-checkpoint-postgres not support fields with pydantic model type? ### System Info System Information ------------------ > OS: Darwin > OS Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:16:46 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T8112 > Python Version: 3.11.9 (main, Aug 12 2024, 16:41:06) [Clang 15.0.0 (clang-1500.3.9.4)] Package Information ------------------- > langchain_core: 0.3.21 > langchain: 0.3.9 > langchain_community: 0.3.8 > langsmith: 0.1.142 > langchain_anthropic: 0.3.0 > langchain_aws: 0.2.7 > langchain_google_genai: 2.0.6 > langchain_google_vertexai: 2.0.8 > langchain_groq: 0.2.1 > langchain_openai: 0.2.10 > langchain_text_splitters: 0.3.2 > langgraph_sdk: 0.1.35 Optional packages not installed ------------------------------- > langserve Other Dependencies ------------------ > aiohttp: 3.10.3 > anthropic: 0.39.0 > anthropic[vertexai]: Installed. No version info available. > async-timeout: Installed. No version info available. > boto3: 1.34.158 > dataclasses-json: 0.6.7 > defusedxml: 0.7.1 > filetype: 1.2.0 > google-cloud-aiplatform: 1.72.0 > google-cloud-storage: 2.18.2 > google-generativeai: 0.8.3 > groq: 0.9.0 > httpx: 0.27.0 > httpx-sse: 0.4.0 > jsonpatch: 1.33 > langchain-mistralai: Installed. No version info available. > numpy: 1.26.4 > openai: 1.54.4 > orjson: 3.10.7 > packaging: 24.1 > pydantic: 2.9.2 > pydantic-settings: 2.6.1 > PyYAML: 6.0.2 > requests: 2.32.3 > requests-toolbelt: 1.0.0 > SQLAlchemy: 2.0.32 > tenacity: 8.5.0 > tiktoken: 0.7.0 > typing-extensions: 4.12.2
yindo added the invalid label 2026-02-20 17:37:42 -05:00
yindo closed this issue 2026-02-20 17:37:42 -05:00
Author
Owner

@vbarda commented on GitHub (Dec 6, 2024):

could you please provide a full example that reproduces the issue

@vbarda commented on GitHub (Dec 6, 2024): could you please provide a full example that reproduces the issue
Author
Owner

@vbarda commented on GitHub (Dec 18, 2024):

Closing due to inactivity

@vbarda commented on GitHub (Dec 18, 2024): Closing due to inactivity
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#343