[PR #5057] serialize/deserialize pandas with pickle fallback #4208

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

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

State: closed
Merged: Yes


Writing custom ser/deser logic for pandas with msgpack (and potentially arrow) blows up quickly. For now, pickling as a fallback works quite well.

This is a great opportunity for open source contributors - will create a follow up issue!

In the meantime, can do something like:

from langgraph.graph import StateGraph, START
from langgraph.checkpoint.memory import MemorySaver
from typing_extensions import TypedDict
from langgraph.types import interrupt, Command
from langchain_core.runnables import RunnableConfig


class State(TypedDict):
    data: pd.DataFrame


def node(state: State) -> dict[str, pd.DataFrame]:
    value = interrupt("This is an interrupt")
    return {"data": pd.DataFrame({"a": [1, 2, 3], "b": ["x", "y", "z"]})}


graph = StateGraph(State)
graph.add_node("start", node)
graph.add_edge(START, "start")
compiled_graph = graph.compile(
    checkpointer=MemorySaver(serde=JsonPlusSerializer(pickle_fallback=True))
)

config: RunnableConfig = {"configurable": {"thread_id": 1}}
result = compiled_graph.invoke({}, config=config)

print(result)
state = compiled_graph.get_state(config=config)
print(state)
**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/5057 **State:** closed **Merged:** Yes --- Writing custom ser/deser logic for pandas with msgpack (and potentially arrow) blows up quickly. For now, pickling as a fallback works quite well. This is a great opportunity for open source contributors - will create a follow up issue! In the meantime, can do something like: ```py from langgraph.graph import StateGraph, START from langgraph.checkpoint.memory import MemorySaver from typing_extensions import TypedDict from langgraph.types import interrupt, Command from langchain_core.runnables import RunnableConfig class State(TypedDict): data: pd.DataFrame def node(state: State) -> dict[str, pd.DataFrame]: value = interrupt("This is an interrupt") return {"data": pd.DataFrame({"a": [1, 2, 3], "b": ["x", "y", "z"]})} graph = StateGraph(State) graph.add_node("start", node) graph.add_edge(START, "start") compiled_graph = graph.compile( checkpointer=MemorySaver(serde=JsonPlusSerializer(pickle_fallback=True)) ) config: RunnableConfig = {"configurable": {"thread_id": 1}} result = compiled_graph.invoke({}, config=config) print(result) state = compiled_graph.get_state(config=config) print(state) ```
yindo added the pull-request label 2026-02-20 17:49:50 -05:00
yindo closed this issue 2026-02-20 17:49:50 -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#4208