Parallel execution of nodes do not seem to work. #480

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

Originally created by @tkbala on GitHub (Feb 27, 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

Image

import operator
from typing import Annotated, TypedDict

from langgraph.graph import END, START, StateGraph


class State(TypedDict):
    aggregate: Annotated[list, operator.add]


class ReturnNodeValue:
    def __init__(self, node_secret: str) -> None:
        self._value = node_secret

    def __call__(self, state: State) -> State:
        print(f"Adding {self._value} to {state['aggregate']}")
        return {"aggregate": [self._value]}


builder = StateGraph(State)
for s in "abcd":
    builder.add_node(s, ReturnNodeValue(f"I'm {s.upper()}"))

builder.add_edge(START, "a")
builder.add_edge(START, "b")
builder.add_edge("a", "c")
builder.add_edge("b", "d")
builder.add_edge(["c", "d"], END)

graph = builder.compile()
graph.get_graph().draw_mermaid_png(output_file_path="example.png")

graph.invoke({"aggregate": []})

Error Message and Stack Trace (if applicable)


Description

I get the following.

Adding I'm A to []
Adding I'm B to []
Adding I'm C to ["I'm A", "I'm B"]
Adding I'm D to ["I'm A", "I'm B"]

{'aggregate': ["I'm A", "I'm B", "I'm C", "I'm D"]}

However, I expect "I'm A" and "I'm C" to be added independently to pathway of "I'm B" and "I'm D". They need to merged only in the end. So I would expect

Adding I'm A to []
Adding I'm C to ["I'm A"]
Adding I'm B to []
Adding I'm D to ["I'm B"]

{'aggregate': ["I'm A", "I'm C", "I'm B", "I'm D"]}

System Info

System Information

OS: Linux
OS Version: 20.04.1-Ubuntu
Python Version: 3.10.16

Package Information

langchain_core: 0.3.37
langchain: 0.3.10
langchain_community: 0.3.10
langsmith: 0.1.147
langchain_anthropic: 0.3.0
langchain_astradb: 0.5.2
langchain_aws: 0.2.7
langchain_chroma: 0.1.4
langchain_cohere: 0.3.3
langchain_elasticsearch: 0.3.0
langchain_experimental: 0.3.4
langchain_google_calendar_tools: 0.0.1
langchain_google_community: 2.0.3
langchain_google_genai: 2.0.6
langchain_google_vertexai: 2.0.7
langchain_groq: 0.2.1
langchain_milvus: 0.1.7
langchain_mistralai: 0.2.3
langchain_mongodb: 0.2.0
langchain_nvidia: Installed. No version info available.
langchain_nvidia_ai_endpoints: 0.3.5
langchain_ollama: 0.2.1
langchain_openai: 0.3.6
langchain_pinecone: 0.2.2
langchain_tests: 0.3.11
langchain_text_splitters: 0.3.6
langchain_unstructured: 0.1.5
langchainhub: 0.1.21
langgraph_sdk: 0.1.51

Optional packages not installed

langserve

Other Dependencies

aiohttp: 3.10.11
anthropic: 0.45.2
anthropic[vertexai]: Installed. No version info available.
astrapy: 1.5.2
async-timeout: 4.0.3
beautifulsoup4: 4.12.3
boto3: 1.34.162
chromadb: 0.5.23
cohere: 5.13.12
dataclasses-json: 0.6.7
db-dtypes: Installed. No version info available.
defusedxml: 0.7.1
elasticsearch[vectorstore-mmr]: Installed. No version info available.
fastapi: 0.115.8
filetype: 1.2.0
gapic-google-longrunning: Installed. No version info available.
google-api-core: 2.24.1
google-api-python-client: 2.154.0
google-api-python-client>=2.104.0: Installed. No version info available.
google-auth-httplib2: 0.2.0
google-auth-oauthlib: 1.2.1
google-auth-oauthlib>=1.1.0: Installed. No version info available.
google-cloud-aiplatform: 1.79.0
google-cloud-bigquery: 3.29.0
google-cloud-bigquery-storage: Installed. No version info available.
google-cloud-contentwarehouse: Installed. No version info available.
google-cloud-core: 2.4.1
google-cloud-discoveryengine: Installed. No version info available.
google-cloud-documentai: Installed. No version info available.
google-cloud-documentai-toolbox: Installed. No version info available.
google-cloud-speech: Installed. No version info available.
google-cloud-storage: 2.19.0
google-cloud-texttospeech: Installed. No version info available.
google-cloud-translate: Installed. No version info available.
google-cloud-vision: Installed. No version info available.
google-generativeai: 0.8.4
googlemaps: Installed. No version info available.
groq: 0.18.0
grpcio: 1.67.1
httpx: 0.27.2
httpx-sse: 0.4.0
httpx<1,>=0.25.0: Installed. No version info available.
jsonpatch<2.0,>=1.33: Installed. No version info available.
langchain-core<1.0.0,>=0.3.34: Installed. No version info available.
langchain-core<1.0.0,>=0.3.35: Installed. No version info available.
langchain>=0.0.335: Installed. No version info available.
langsmith-pyo3: Installed. No version info available.
langsmith<0.4,>=0.1.125: Installed. No version info available.
numpy: 1.26.4
numpy<2.0.0,>=1.24.0;: Installed. No version info available.
numpy<3,>=1.26.2;: Installed. No version info available.
ollama: 0.4.7
openai<2.0.0,>=1.58.1: Installed. No version info available.
orjson: 3.10.15
packaging: 24.2
packaging<25,>=23.2: Installed. No version info available.
pandas: 2.2.2
pillow: 11.0.0
pinecone: 5.4.2
protobuf>=4.25.0: Installed. No version info available.
pyarrow: 17.0.0
pydantic: 2.10.6
pydantic-settings: 2.4.0
pydantic<3.0.0,>=2.5.2;: Installed. No version info available.
pydantic<3.0.0,>=2.7.4;: Installed. No version info available.
pymilvus: 2.5.4
pymongo: 4.10.1
pytest-asyncio<1,>=0.20: Installed. No version info available.
pytest-socket<1,>=0.6.0: Installed. No version info available.
pytest<9,>=7: Installed. No version info available.
pytz>=2023.3.post1: Installed. No version info available.
PyYAML: 6.0.2
PyYAML>=5.3: Installed. No version info available.
requests: 2.32.3
requests-toolbelt: 1.0.0
SQLAlchemy: 2.0.38
syrupy<5,>=4: Installed. No version info available.
tabulate: 0.9.0
tenacity: 8.5.0
tenacity!=8.4.0,<10.0.0,>=8.1.0: Installed. No version info available.
tiktoken<1,>=0.7: Installed. No version info available.
tokenizers: 0.20.3
types-requests: 2.32.0.20241016
typing-extensions>=4.7: Installed. No version info available.
unstructured-client: 0.25.9
unstructured[all-docs]: Installed. No version info available.

Originally created by @tkbala on GitHub (Feb 27, 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 ![Image](https://github.com/user-attachments/assets/8d18df63-b065-4aec-b3a2-c70dfc31a17c) ```python import operator from typing import Annotated, TypedDict from langgraph.graph import END, START, StateGraph class State(TypedDict): aggregate: Annotated[list, operator.add] class ReturnNodeValue: def __init__(self, node_secret: str) -> None: self._value = node_secret def __call__(self, state: State) -> State: print(f"Adding {self._value} to {state['aggregate']}") return {"aggregate": [self._value]} builder = StateGraph(State) for s in "abcd": builder.add_node(s, ReturnNodeValue(f"I'm {s.upper()}")) builder.add_edge(START, "a") builder.add_edge(START, "b") builder.add_edge("a", "c") builder.add_edge("b", "d") builder.add_edge(["c", "d"], END) graph = builder.compile() graph.get_graph().draw_mermaid_png(output_file_path="example.png") graph.invoke({"aggregate": []}) ``` ### Error Message and Stack Trace (if applicable) ```shell ``` ### Description I get the following. Adding I'm A to [] Adding I'm B to [] Adding I'm C to ["I'm A", "I'm B"] Adding I'm D to ["I'm A", "I'm B"] {'aggregate': ["I'm A", "I'm B", "I'm C", "I'm D"]} --------------- However, I expect "I'm A" and "I'm C" to be added independently to pathway of "I'm B" and "I'm D". They need to merged only in the end. So I would expect Adding I'm A to [] Adding I'm C to ["I'm A"] Adding I'm B to [] Adding I'm D to ["I'm B"] {'aggregate': ["I'm A", "I'm C", "I'm B", "I'm D"]} ### System Info System Information ------------------ > OS: Linux > OS Version: 20.04.1-Ubuntu > Python Version: 3.10.16 Package Information ------------------- > langchain_core: 0.3.37 > langchain: 0.3.10 > langchain_community: 0.3.10 > langsmith: 0.1.147 > langchain_anthropic: 0.3.0 > langchain_astradb: 0.5.2 > langchain_aws: 0.2.7 > langchain_chroma: 0.1.4 > langchain_cohere: 0.3.3 > langchain_elasticsearch: 0.3.0 > langchain_experimental: 0.3.4 > langchain_google_calendar_tools: 0.0.1 > langchain_google_community: 2.0.3 > langchain_google_genai: 2.0.6 > langchain_google_vertexai: 2.0.7 > langchain_groq: 0.2.1 > langchain_milvus: 0.1.7 > langchain_mistralai: 0.2.3 > langchain_mongodb: 0.2.0 > langchain_nvidia: Installed. No version info available. > langchain_nvidia_ai_endpoints: 0.3.5 > langchain_ollama: 0.2.1 > langchain_openai: 0.3.6 > langchain_pinecone: 0.2.2 > langchain_tests: 0.3.11 > langchain_text_splitters: 0.3.6 > langchain_unstructured: 0.1.5 > langchainhub: 0.1.21 > langgraph_sdk: 0.1.51 Optional packages not installed ------------------------------- > langserve Other Dependencies ------------------ > aiohttp: 3.10.11 > anthropic: 0.45.2 > anthropic[vertexai]: Installed. No version info available. > astrapy: 1.5.2 > async-timeout: 4.0.3 > beautifulsoup4: 4.12.3 > boto3: 1.34.162 > chromadb: 0.5.23 > cohere: 5.13.12 > dataclasses-json: 0.6.7 > db-dtypes: Installed. No version info available. > defusedxml: 0.7.1 > elasticsearch[vectorstore-mmr]: Installed. No version info available. > fastapi: 0.115.8 > filetype: 1.2.0 > gapic-google-longrunning: Installed. No version info available. > google-api-core: 2.24.1 > google-api-python-client: 2.154.0 > google-api-python-client>=2.104.0: Installed. No version info available. > google-auth-httplib2: 0.2.0 > google-auth-oauthlib: 1.2.1 > google-auth-oauthlib>=1.1.0: Installed. No version info available. > google-cloud-aiplatform: 1.79.0 > google-cloud-bigquery: 3.29.0 > google-cloud-bigquery-storage: Installed. No version info available. > google-cloud-contentwarehouse: Installed. No version info available. > google-cloud-core: 2.4.1 > google-cloud-discoveryengine: Installed. No version info available. > google-cloud-documentai: Installed. No version info available. > google-cloud-documentai-toolbox: Installed. No version info available. > google-cloud-speech: Installed. No version info available. > google-cloud-storage: 2.19.0 > google-cloud-texttospeech: Installed. No version info available. > google-cloud-translate: Installed. No version info available. > google-cloud-vision: Installed. No version info available. > google-generativeai: 0.8.4 > googlemaps: Installed. No version info available. > groq: 0.18.0 > grpcio: 1.67.1 > httpx: 0.27.2 > httpx-sse: 0.4.0 > httpx<1,>=0.25.0: Installed. No version info available. > jsonpatch<2.0,>=1.33: Installed. No version info available. > langchain-core<1.0.0,>=0.3.34: Installed. No version info available. > langchain-core<1.0.0,>=0.3.35: Installed. No version info available. > langchain>=0.0.335: Installed. No version info available. > langsmith-pyo3: Installed. No version info available. > langsmith<0.4,>=0.1.125: Installed. No version info available. > numpy: 1.26.4 > numpy<2.0.0,>=1.24.0;: Installed. No version info available. > numpy<3,>=1.26.2;: Installed. No version info available. > ollama: 0.4.7 > openai<2.0.0,>=1.58.1: Installed. No version info available. > orjson: 3.10.15 > packaging: 24.2 > packaging<25,>=23.2: Installed. No version info available. > pandas: 2.2.2 > pillow: 11.0.0 > pinecone: 5.4.2 > protobuf>=4.25.0: Installed. No version info available. > pyarrow: 17.0.0 > pydantic: 2.10.6 > pydantic-settings: 2.4.0 > pydantic<3.0.0,>=2.5.2;: Installed. No version info available. > pydantic<3.0.0,>=2.7.4;: Installed. No version info available. > pymilvus: 2.5.4 > pymongo: 4.10.1 > pytest-asyncio<1,>=0.20: Installed. No version info available. > pytest-socket<1,>=0.6.0: Installed. No version info available. > pytest<9,>=7: Installed. No version info available. > pytz>=2023.3.post1: Installed. No version info available. > PyYAML: 6.0.2 > PyYAML>=5.3: Installed. No version info available. > requests: 2.32.3 > requests-toolbelt: 1.0.0 > SQLAlchemy: 2.0.38 > syrupy<5,>=4: Installed. No version info available. > tabulate: 0.9.0 > tenacity: 8.5.0 > tenacity!=8.4.0,<10.0.0,>=8.1.0: Installed. No version info available. > tiktoken<1,>=0.7: Installed. No version info available. > tokenizers: 0.20.3 > types-requests: 2.32.0.20241016 > typing-extensions>=4.7: Installed. No version info available. > unstructured-client: 0.25.9 > unstructured[all-docs]: Installed. No version info available.
yindo closed this issue 2026-02-20 17:40:19 -05:00
Author
Owner

@vbarda commented on GitHub (Feb 27, 2025):

This is the expected behavior in LangGraph - execution proceeds in supersteps, so all nodes running in parallel during the same superstep are executed first, e.g. A and B are executed first, followed by C and D. Check out this doc for more info https://langchain-ai.github.io/langgraph/how-tos/branching/

@vbarda commented on GitHub (Feb 27, 2025): This is the expected behavior in LangGraph - execution proceeds in supersteps, so all nodes running in parallel during the same superstep are executed first, e.g. A and B are executed first, followed by C and D. Check out this doc for more info https://langchain-ai.github.io/langgraph/how-tos/branching/
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#480