Document Pydantic Schema Usage #357

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

Originally created by @eyurtsev on GitHub (Dec 12, 2024).

Originally assigned to: @eyurtsev on GitHub.

Issue with current documentation:

from langgraph.graph import StateGraph
from langgraph.constants import START
from pydantic import BaseModel

class Foo(BaseModel):
    x: int
    y: str

def node(state: Foo):
    """This parent node will invoke the subgraph."""
    return state

builder = StateGraph(Foo)
builder.add_node("node", node)
builder.add_edge(START, "node")
graph = builder.compile()
result = graph.invoke(Foo(x=3, y="hello"))
Foo(**result)

Idea or request for content:

Figure out where to document current behavior + run time coercion

Originally created by @eyurtsev on GitHub (Dec 12, 2024). Originally assigned to: @eyurtsev on GitHub. ### Issue with current documentation: ```python from langgraph.graph import StateGraph from langgraph.constants import START from pydantic import BaseModel class Foo(BaseModel): x: int y: str def node(state: Foo): """This parent node will invoke the subgraph.""" return state builder = StateGraph(Foo) builder.add_node("node", node) builder.add_edge(START, "node") graph = builder.compile() result = graph.invoke(Foo(x=3, y="hello")) Foo(**result) ``` ### Idea or request for content: Figure out where to document current behavior + run time coercion
yindo added the maintainer label 2026-02-20 17:38:13 -05:00
yindo closed this issue 2026-02-20 17:38:15 -05:00
Author
Owner

@hinthornw commented on GitHub (Dec 16, 2024):

Another point here is that if you use BaseMessage without the add_messages reducer (or an equivalent), messages you send over the wire will be deserialized as just that.
instead should use AnyMessage.

@hinthornw commented on GitHub (Dec 16, 2024): Another point here is that if you use BaseMessage without the `add_messages` reducer (or an equivalent), messages you send over the wire will be deserialized as just that. instead should use AnyMessage.
Author
Owner

@YassinNouh21 commented on GitHub (Feb 26, 2025):

@eyurtsev @vbarda can you look at this pr #3588

@YassinNouh21 commented on GitHub (Feb 26, 2025): @eyurtsev @vbarda can you look at this pr #3588
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#357