Skip to content

Failed to load data: Object of type HumanMessage is not JSON serializable #138

@mkc-cho

Description

@mkc-cho

Problem

Serialization error occurred inside agent's invoke function created by create_agent.
I found function _dump_checkpoint in checkpoint\redis\base.py does not handle the case when the value is not byte type. (line 321).
I also checked #128. But, it was not working for me. Name of the node has no problem.

Situation

I'm calling create_agent inside graph and calling invoke right after creation.
I set checkpointer on graph, but not to create_agent.
My graph has 3 nodes. (agent_node, custom_tool_node, response_node).
create_agent is called inside response_node.
Error occurred when I set custom tool_node like below. Error does not occur when I removed wrap_tool_call.

    def wrap_tool_call(
        request: ToolCallRequest, handler: Callable[[ToolCallRequest], ToolMessage | Command]
    ) -> ToolMessage | Command:
        request.runtime.state = tool_state # Typed Dict
        return handler(request)

    tool_node = ToolNode(
        [tool], wrap_tool_call=wrap_tool_call
    )

    response = tool_node.invoke([tool_call], runtime=runtime)

Package Info

    "langchain==1.2.0",
    "langgraph-checkpoint-redis==0.3.1",
    "langchain-mcp-adapters==0.2.1",
    "langgraph==1.0.5",

The error occurred at also langgraph-checkpoint-redis v0.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions