Calling .astream inside of another graph's .astream_events will set stream_mode="value" regardless of config #304

Closed
opened 2026-02-20 17:36:00 -05:00 by yindo · 4 comments
Owner

Originally created by @lucaslulucaslu on GitHub (Nov 6, 2024).

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangGraph/LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangGraph/LangChain rather than my code.
  • I am sure this is better as an issue rather than a GitHub discussion, since this is a LangGraph bug and not a design question.

Example Code

cannot have code here due to security issue

Error Message and Stack Trace (if applicable)

No response

Description

I have a graph A streaming LLM tokens, I tested it and can confirm I get updates as streaming. Then I have another graph B which is invoked by B.astream_events, then invoke A.astream, I can only get values of every GraphState, no matter I set stream_mode to "value" or "update"

System Info

latest langgraph
mac
python 3.12

Originally created by @lucaslulucaslu on GitHub (Nov 6, 2024). ### Checked other resources - [X] I added a very descriptive title to this issue. - [X] I searched the [LangGraph](https://langchain-ai.github.io/langgraph/)/LangChain documentation with the integrated search. - [X] I used the GitHub search to find a similar question and didn't find it. - [X] I am sure that this is a bug in LangGraph/LangChain rather than my code. - [X] I am sure this is better as an issue [rather than a GitHub discussion](https://github.com/langchain-ai/langgraph/discussions/new/choose), since this is a LangGraph bug and not a design question. ### Example Code ```python cannot have code here due to security issue ``` ### Error Message and Stack Trace (if applicable) _No response_ ### Description I have a graph A streaming LLM tokens, I tested it and can confirm I get updates as streaming. Then I have another graph B which is invoked by B.astream_events, then invoke A.astream, I can only get values of every GraphState, no matter I set stream_mode to "value" or "update" ### System Info latest langgraph mac python 3.12
yindo closed this issue 2026-02-20 17:36:00 -05:00
Author
Owner

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

@lucaslulucaslu could you write some pseudocode to illustrate this issue better?

@vbarda commented on GitHub (Nov 6, 2024): @lucaslulucaslu could you write some pseudocode to illustrate this issue better?
Author
Owner

@lucaslulucaslu commented on GitHub (Nov 9, 2024):

Sure @vbarda

from langgraph.graph import StateGraph,START,END
from pydantic import BaseModel

class GraphState1(BaseModel):
    a: int = 0
    b: int = 0

def graph1_node1(state: GraphState1):
    a=state.a
    a+=1
    return {"a":a}
def graph1_node2(state: GraphState1):
    b=state.b
    b+=1
    return {"b":b}


graph1=StateGraph(GraphState1)
graph1.add_node(graph1_node1.__name__,graph1_node1)
graph1.add_node(graph1_node2.__name__,graph1_node2)
graph1.add_edge(START,graph1_node1.__name__)
graph1.add_edge(graph1_node1.__name__,graph1_node2.__name__)
graph1.add_edge(graph1_node2.__name__,END)
graph1_app= graph1.compile()

async for chunk in graph1_app.astream({"a":0,"b":0}):
    print(chunk)

This will output updates as expected:

{'graph1_node1': {'a': 1}}
{'graph1_node2': {'b': 1}}

However if we invoke this exactly same graph in another graph:

class GraphState2(BaseModel):
    c: int = 0
    d: int = 0

async def graph2_node1(state: GraphState2):
    async for chunk in graph1_app.astream({"a":0,"b":0},stream_mode="updates"):
        print(chunk)
    c=state.c
    c+=1
    return {"c":c}
def graph2_node2(state: GraphState2):
    d=state.d
    d+=1
    return {"d":d}

graph2=StateGraph(GraphState2)
graph2.add_node(graph2_node1.__name__,graph2_node1)
graph2.add_node(graph2_node2.__name__,graph2_node2)
graph2.add_edge(START,graph2_node1.__name__)
graph2.add_edge(graph2_node1.__name__,graph2_node2.__name__)
graph2.add_edge(graph2_node2.__name__,END)
graph2_app= graph2.compile()

async for chunk in graph2_app.astream_events({"c":0,"d":0},version="v2"):
    pass

graph2 does nothing but invoke graph1 in graph2_node1, and the print out result is:

{'a': 0, 'b': 0}
{'a': 1, 'b': 0}
{'a': 1, 'b': 1}

even I explicitly use async for chunk in graph1_app.astream({"a":0,"b":0},stream_mode="updates"): with stream_mode ="updates"

@lucaslulucaslu commented on GitHub (Nov 9, 2024): Sure @vbarda ``` from langgraph.graph import StateGraph,START,END from pydantic import BaseModel class GraphState1(BaseModel): a: int = 0 b: int = 0 def graph1_node1(state: GraphState1): a=state.a a+=1 return {"a":a} def graph1_node2(state: GraphState1): b=state.b b+=1 return {"b":b} graph1=StateGraph(GraphState1) graph1.add_node(graph1_node1.__name__,graph1_node1) graph1.add_node(graph1_node2.__name__,graph1_node2) graph1.add_edge(START,graph1_node1.__name__) graph1.add_edge(graph1_node1.__name__,graph1_node2.__name__) graph1.add_edge(graph1_node2.__name__,END) graph1_app= graph1.compile() async for chunk in graph1_app.astream({"a":0,"b":0}): print(chunk) ``` This will output updates as expected: ``` {'graph1_node1': {'a': 1}} {'graph1_node2': {'b': 1}} ``` However if we invoke this exactly same graph in another graph: ``` class GraphState2(BaseModel): c: int = 0 d: int = 0 async def graph2_node1(state: GraphState2): async for chunk in graph1_app.astream({"a":0,"b":0},stream_mode="updates"): print(chunk) c=state.c c+=1 return {"c":c} def graph2_node2(state: GraphState2): d=state.d d+=1 return {"d":d} graph2=StateGraph(GraphState2) graph2.add_node(graph2_node1.__name__,graph2_node1) graph2.add_node(graph2_node2.__name__,graph2_node2) graph2.add_edge(START,graph2_node1.__name__) graph2.add_edge(graph2_node1.__name__,graph2_node2.__name__) graph2.add_edge(graph2_node2.__name__,END) graph2_app= graph2.compile() async for chunk in graph2_app.astream_events({"c":0,"d":0},version="v2"): pass ``` graph2 does nothing but invoke graph1 in graph2_node1, and the print out result is: ``` {'a': 0, 'b': 0} {'a': 1, 'b': 0} {'a': 1, 'b': 1} ``` even I explicitly use `async for chunk in graph1_app.astream({"a":0,"b":0},stream_mode="updates"):` with stream_mode ="updates"
Author
Owner

@OneCoin123 commented on GitHub (May 11, 2025):

I met the same problem. Is there any method to stream a subgraph calling in update mode? Or it is simply restricted to use stream_mode='values' for now?

@OneCoin123 commented on GitHub (May 11, 2025): I met the same problem. Is there any method to stream a subgraph calling in update mode? Or it is simply restricted to use stream_mode='values' for now?
Author
Owner

@nfcampos commented on GitHub (May 23, 2025):

Fixed in #4806

@nfcampos commented on GitHub (May 23, 2025): Fixed in #4806
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#304