Node expected to run waits for parallel node #619

Closed
opened 2026-02-20 17:41:00 -05:00 by yindo · 1 comment
Owner

Originally created by @ltoniazzi on GitHub (May 13, 2025).

Checked other resources

  • This is a bug, not a usage question. For questions, please use GitHub Discussions.
  • I added a clear and detailed title that summarizes the issue.
  • I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example).
  • I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue.

Example Code

from langgraph.graph import END, START, StateGraph
from datetime import datetime
import asyncio
import operator
from typing import Annotated
from larg_graph.state import BaseState


class State(BaseState):
    messages: Annotated[list[str], operator.add]

class SleepyNode:
    def __init__(self, name, sleep) -> None:
        self.sleep = sleep
        self.name = name

    async def __call__(self, state: State) -> dict:  # noqa: ARG002
        await asyncio.sleep(self.sleep)
        timestamp = datetime.now().strftime("%H:%M:%S")
        return {
            "messages": [f"{self.name} - slept {self.sleep} - {timestamp=}"],
            } 


graph_builder = StateGraph(State)

graph_builder.add_node("node0", SleepyNode(name="node0", sleep=3.0))
graph_builder.add_node("node1", SleepyNode(name="node1", sleep=0.0))
graph_builder.add_node("node2", SleepyNode(name="node2", sleep=1.0))
graph_builder.add_edge(START, "node0")
graph_builder.add_edge(START, "node1")
graph_builder.add_edge("node1", "node2")
graph_builder.add_edge(["node2", "node0"], END)


graph = graph_builder.compile()

response = asyncio.run(graph.ainvoke(input={"messages": ["Hello"]}))

for resp in response["messages"]:
    print(resp)

Error Message and Stack Trace (if applicable)

Hello
a - slept 3.0 - timestamp='17:01:11'
b - slept 0.0 - timestamp='17:01:08'
b_2 - slept 1.0 - timestamp='17:01:12'

Description

I have a graph like this:

Image

But it seems that b_2 waits for a to finish, as the timestamp is 1 second after the end of a instead of 1 second after the end of b.

But there is no reason for b_2 to wait for a. Is this a bug? Or I am supposed to always put b and b_2 into a single node?

From the example here "Extended example: unequal length branches" it sounds that a and b are forced into the same superstep, and b_2 will go into a subsequent superstep. Is this the case?

System Info

System Information

OS: Darwin
OS Version: Darwin Kernel Version 24.3.0: Thu Jan 2 20:23:36 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T8112
Python Version: 3.13.1 (main, Dec 3 2024, 17:59:52) [Clang 16.0.0 (clang-1600.0.26.4)]

Package Information

langchain_core: 0.3.59
langchain: 0.3.25
langsmith: 0.3.42
langchain_openai: 0.3.16
langchain_text_splitters: 0.3.8
langgraph_api: 0.2.27
langgraph_cli: 0.2.10
langgraph_license: Installed. No version info available.
langgraph_runtime: Installed. No version info available.
langgraph_runtime_inmem: 0.0.11
langgraph_sdk: 0.1.69

Optional packages not installed

langserve

Other Dependencies

async-timeout<5.0.0,>=4.0.0;: Installed. No version info available.
blockbuster: 1.5.24
click: 8.2.0
cloudpickle: 3.1.1
cryptography: 44.0.3
httpx: 0.28.1
jsonpatch<2.0,>=1.33: Installed. No version info available.
jsonschema-rs: 0.29.1
langchain-anthropic;: Installed. No version info available.
langchain-aws;: Installed. No version info available.
langchain-azure-ai;: Installed. No version info available.
langchain-cohere;: Installed. No version info available.
langchain-community;: Installed. No version info available.
langchain-core<1.0.0,>=0.3.51: Installed. No version info available.
langchain-core<1.0.0,>=0.3.58: Installed. No version info available.
langchain-deepseek;: Installed. No version info available.
langchain-fireworks;: Installed. No version info available.
langchain-google-genai;: Installed. No version info available.
langchain-google-vertexai;: Installed. No version info available.
langchain-groq;: Installed. No version info available.
langchain-huggingface;: Installed. No version info available.
langchain-mistralai;: Installed. No version info available.
langchain-ollama;: Installed. No version info available.
langchain-openai;: Installed. No version info available.
langchain-perplexity;: Installed. No version info available.
langchain-text-splitters<1.0.0,>=0.3.8: Installed. No version info available.
langchain-together;: Installed. No version info available.
langchain-xai;: Installed. No version info available.
langgraph: 0.4.3
langgraph-checkpoint: 2.0.25
langsmith-pyo3: Installed. No version info available.
langsmith<0.4,>=0.1.125: Installed. No version info available.
langsmith<0.4,>=0.1.17: Installed. No version info available.
openai-agents: Installed. No version info available.
openai<2.0.0,>=1.68.2: Installed. No version info available.
opentelemetry-api: Installed. No version info available.
opentelemetry-exporter-otlp-proto-http: Installed. No version info available.
opentelemetry-sdk: Installed. No version info available.
orjson: 3.10.18
packaging: 24.2
packaging<25,>=23.2: Installed. No version info available.
pydantic: 2.11.4
pydantic<3.0.0,>=2.5.2;: Installed. No version info available.
pydantic<3.0.0,>=2.7.4: Installed. No version info available.
pydantic<3.0.0,>=2.7.4;: Installed. No version info available.
pyjwt: 2.10.1
pytest: 8.3.5
python-dotenv: 1.1.0
PyYAML>=5.3: Installed. No version info available.
requests: 2.32.3
requests-toolbelt: 1.0.0
requests<3,>=2: Installed. No version info available.
rich: Installed. No version info available.
SQLAlchemy<3,>=1.4: Installed. No version info available.
sse-starlette: 2.1.3
starlette: 0.46.2
structlog: 25.3.0
tenacity: 9.1.2
tenacity!=8.4.0,<10.0.0,>=8.1.0: Installed. No version info available.
tiktoken<1,>=0.7: Installed. No version info available.
truststore: 0.10.1
typing-extensions>=4.7: Installed. No version info available.
uvicorn: 0.34.2
watchfiles: 1.0.5
zstandard: 0.23.0

Originally created by @ltoniazzi on GitHub (May 13, 2025). ### Checked other resources - [x] This is a bug, not a usage question. For questions, please use GitHub Discussions. - [x] I added a clear and detailed title that summarizes the issue. - [x] I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example). - [x] I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue. ### Example Code ```python from langgraph.graph import END, START, StateGraph from datetime import datetime import asyncio import operator from typing import Annotated from larg_graph.state import BaseState class State(BaseState): messages: Annotated[list[str], operator.add] class SleepyNode: def __init__(self, name, sleep) -> None: self.sleep = sleep self.name = name async def __call__(self, state: State) -> dict: # noqa: ARG002 await asyncio.sleep(self.sleep) timestamp = datetime.now().strftime("%H:%M:%S") return { "messages": [f"{self.name} - slept {self.sleep} - {timestamp=}"], } graph_builder = StateGraph(State) graph_builder.add_node("node0", SleepyNode(name="node0", sleep=3.0)) graph_builder.add_node("node1", SleepyNode(name="node1", sleep=0.0)) graph_builder.add_node("node2", SleepyNode(name="node2", sleep=1.0)) graph_builder.add_edge(START, "node0") graph_builder.add_edge(START, "node1") graph_builder.add_edge("node1", "node2") graph_builder.add_edge(["node2", "node0"], END) graph = graph_builder.compile() response = asyncio.run(graph.ainvoke(input={"messages": ["Hello"]})) for resp in response["messages"]: print(resp) ``` ### Error Message and Stack Trace (if applicable) ```shell Hello a - slept 3.0 - timestamp='17:01:11' b - slept 0.0 - timestamp='17:01:08' b_2 - slept 1.0 - timestamp='17:01:12' ``` ### Description I have a graph like this: ![Image](https://github.com/user-attachments/assets/9f347571-a204-4d7f-b8f9-30ac450794e3) But it seems that `b_2` waits for `a` to finish, as the timestamp is 1 second after the end of `a` instead of 1 second after the end of `b`. But there is no reason for `b_2` to wait for `a`. Is this a bug? Or I am supposed to always put `b` and `b_2` into a single node? From the example [here "Extended example: unequal length branches"](https://langchain-ai.github.io/langgraph/how-tos/graph-api/#langgraph.graph.state.CompiledStateGraph.ainvoke) it sounds that `a` and `b` are forced into the same superstep, and `b_2` will go into a subsequent superstep. Is this the case? ### System Info System Information ------------------ > OS: Darwin > OS Version: Darwin Kernel Version 24.3.0: Thu Jan 2 20:23:36 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T8112 > Python Version: 3.13.1 (main, Dec 3 2024, 17:59:52) [Clang 16.0.0 (clang-1600.0.26.4)] Package Information ------------------- > langchain_core: 0.3.59 > langchain: 0.3.25 > langsmith: 0.3.42 > langchain_openai: 0.3.16 > langchain_text_splitters: 0.3.8 > langgraph_api: 0.2.27 > langgraph_cli: 0.2.10 > langgraph_license: Installed. No version info available. > langgraph_runtime: Installed. No version info available. > langgraph_runtime_inmem: 0.0.11 > langgraph_sdk: 0.1.69 Optional packages not installed ------------------------------- > langserve Other Dependencies ------------------ > async-timeout<5.0.0,>=4.0.0;: Installed. No version info available. > blockbuster: 1.5.24 > click: 8.2.0 > cloudpickle: 3.1.1 > cryptography: 44.0.3 > httpx: 0.28.1 > jsonpatch<2.0,>=1.33: Installed. No version info available. > jsonschema-rs: 0.29.1 > langchain-anthropic;: Installed. No version info available. > langchain-aws;: Installed. No version info available. > langchain-azure-ai;: Installed. No version info available. > langchain-cohere;: Installed. No version info available. > langchain-community;: Installed. No version info available. > langchain-core<1.0.0,>=0.3.51: Installed. No version info available. > langchain-core<1.0.0,>=0.3.58: Installed. No version info available. > langchain-deepseek;: Installed. No version info available. > langchain-fireworks;: Installed. No version info available. > langchain-google-genai;: Installed. No version info available. > langchain-google-vertexai;: Installed. No version info available. > langchain-groq;: Installed. No version info available. > langchain-huggingface;: Installed. No version info available. > langchain-mistralai;: Installed. No version info available. > langchain-ollama;: Installed. No version info available. > langchain-openai;: Installed. No version info available. > langchain-perplexity;: Installed. No version info available. > langchain-text-splitters<1.0.0,>=0.3.8: Installed. No version info available. > langchain-together;: Installed. No version info available. > langchain-xai;: Installed. No version info available. > langgraph: 0.4.3 > langgraph-checkpoint: 2.0.25 > langsmith-pyo3: Installed. No version info available. > langsmith<0.4,>=0.1.125: Installed. No version info available. > langsmith<0.4,>=0.1.17: Installed. No version info available. > openai-agents: Installed. No version info available. > openai<2.0.0,>=1.68.2: Installed. No version info available. > opentelemetry-api: Installed. No version info available. > opentelemetry-exporter-otlp-proto-http: Installed. No version info available. > opentelemetry-sdk: Installed. No version info available. > orjson: 3.10.18 > packaging: 24.2 > packaging<25,>=23.2: Installed. No version info available. > pydantic: 2.11.4 > pydantic<3.0.0,>=2.5.2;: Installed. No version info available. > pydantic<3.0.0,>=2.7.4: Installed. No version info available. > pydantic<3.0.0,>=2.7.4;: Installed. No version info available. > pyjwt: 2.10.1 > pytest: 8.3.5 > python-dotenv: 1.1.0 > PyYAML>=5.3: Installed. No version info available. > requests: 2.32.3 > requests-toolbelt: 1.0.0 > requests<3,>=2: Installed. No version info available. > rich: Installed. No version info available. > SQLAlchemy<3,>=1.4: Installed. No version info available. > sse-starlette: 2.1.3 > starlette: 0.46.2 > structlog: 25.3.0 > tenacity: 9.1.2 > tenacity!=8.4.0,<10.0.0,>=8.1.0: Installed. No version info available. > tiktoken<1,>=0.7: Installed. No version info available. > truststore: 0.10.1 > typing-extensions>=4.7: Installed. No version info available. > uvicorn: 0.34.2 > watchfiles: 1.0.5 > zstandard: 0.23.0
yindo closed this issue 2026-02-20 17:41:00 -05:00
Author
Owner

@vbarda commented on GitHub (May 13, 2025):

This is not a bug, as per the guide you referenced this is the expected behavior:

From the example here "Extended example: unequal length branches" it sounds that a and b are forced into the same superstep, and b_2 will go into a subsequent superstep. Is this the case?

a and b run in the same superstep, so b_2 can't start until both a and b run. you could put b and b_2 in a subgraph, if needed, and this will make both of them run in the same superstep

@vbarda commented on GitHub (May 13, 2025): This is not a bug, as per the guide you referenced this is the expected behavior: > From the example [here "Extended example: unequal length branches"](https://langchain-ai.github.io/langgraph/how-tos/graph-api/#langgraph.graph.state.CompiledStateGraph.ainvoke) it sounds that a and b are forced into the same superstep, and b_2 will go into a subsequent superstep. Is this the case? `a` and `b` run in the same superstep, so `b_2` can't start until both `a` and `b` run. you could put `b` and `b_2` in a subgraph, if needed, and this will make both of them run in the same superstep
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#619