Streaming updates seem to include unchanged state from subgraphs #139

Closed
opened 2026-02-15 17:16:13 -05:00 by yindo · 1 comment
Owner

Originally created by @shaibt on GitHub (Nov 27, 2024).

I have a two tier hierarchy of graphs with some shared state between the "master" and the "subgraphs".
Each subgraph shares a partial set of state from the master in order to access the relevant current state when initiated, mutate it and return it back to the master.

The issue I'm seeing is that streaming updates seem to include state that was unchanged neither by the master or the subgraphs:

for namespace, type, chunk in supervisor_agent_graph.stream({ "messages": HumanMessage(request.message)}, config, stream_mode=["custom", "updates"], subgraphs=True):
            if type == "updates":
                [(node_name, value)] = chunk.items()
                #value includes state that was never changed
                last_update_value = value

Could it be that the "copying" of state forwards to the subgraph and back to the master is considered a state "update" even when the actual value of the state field does not change and is not updated explicitly by a node in the subgraph?

Originally created by @shaibt on GitHub (Nov 27, 2024). I have a two tier hierarchy of graphs with some shared state between the "master" and the "subgraphs". Each subgraph shares a partial set of state from the master in order to access the relevant current state when initiated, mutate it and return it back to the master. The issue I'm seeing is that streaming updates seem to include state that was unchanged neither by the master or the subgraphs: ``` for namespace, type, chunk in supervisor_agent_graph.stream({ "messages": HumanMessage(request.message)}, config, stream_mode=["custom", "updates"], subgraphs=True): if type == "updates": [(node_name, value)] = chunk.items() #value includes state that was never changed last_update_value = value ``` Could it be that the "copying" of state forwards to the subgraph and back to the master is considered a state "update" even when the actual value of the state field does not change and is not updated explicitly by a node in the subgraph?
yindo closed this issue 2026-02-15 17:16:13 -05:00
Author
Owner

@dqbd commented on GitHub (Jul 8, 2025):

Hello! Cannot seem to replicate on the following code snippet:

import { AIMessage } from "@langchain/core/messages";
import {
  Annotation,
  MessagesAnnotation,
  START,
  StateGraph,
} from "@langchain/langgraph";

const subgraph = new StateGraph(
  Annotation.Root({
    internal: Annotation<string>,
    messages: MessagesAnnotation.spec.messages,
  }),
)
  .addNode("child", () => ({
    internal: "hello",
    messages: [new AIMessage({ content: "child" })],
  }))
  .addEdge(START, "child")
  .compile();

const graph = new StateGraph(
  Annotation.Root({
    state: Annotation<string>,
    messages: MessagesAnnotation.spec.messages,
  }),
)
  .addNode("parent", () => ({
    state: "parent",
    messages: [new AIMessage({ content: "parent" })],
  }))
  .addNode("child", subgraph)
  .addEdge(START, "parent")
  .addEdge("parent", "child")
  .compile();

for await (const [namespace, type, values] of await graph.stream(
  { messages: [{ type: "human", content: "input" }] },
  { streamMode: ["custom", "updates"], subgraphs: true },
)) {
  console.log(namespace, type, values);
}

Closing for staleness. Feel free to reopen if the issue still persists.

@dqbd commented on GitHub (Jul 8, 2025): Hello! Cannot seem to replicate on the following code snippet: ```typescript import { AIMessage } from "@langchain/core/messages"; import { Annotation, MessagesAnnotation, START, StateGraph, } from "@langchain/langgraph"; const subgraph = new StateGraph( Annotation.Root({ internal: Annotation<string>, messages: MessagesAnnotation.spec.messages, }), ) .addNode("child", () => ({ internal: "hello", messages: [new AIMessage({ content: "child" })], })) .addEdge(START, "child") .compile(); const graph = new StateGraph( Annotation.Root({ state: Annotation<string>, messages: MessagesAnnotation.spec.messages, }), ) .addNode("parent", () => ({ state: "parent", messages: [new AIMessage({ content: "parent" })], })) .addNode("child", subgraph) .addEdge(START, "parent") .addEdge("parent", "child") .compile(); for await (const [namespace, type, values] of await graph.stream( { messages: [{ type: "human", content: "input" }] }, { streamMode: ["custom", "updates"], subgraphs: true }, )) { console.log(namespace, type, values); } ``` Closing for staleness. Feel free to reopen if the issue still persists.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#139