Skip to content

Run graph nodes in parallel #6335

@jsxzhub

Description

@jsxzhub

Checked other resources

  • This is a bug, not a usage question. For questions, please use the LangChain Forum (https://forum.langchain.com/).
  • 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

import operatorfrom typing import Annotated, Anyfrom typing_extensions import TypedDictfrom langgraph.graph import StateGraph, START, END
class State(TypedDict):
# The operator.add reducer fn makes this append-only
aggregate: Annotated[list, operator.add]
def a(state: State):
print(f'Adding "A" to {state["aggregate"]}')
return {"aggregate": ["A"]}
def b(state: State):
print(f'Adding "B" to {state["aggregate"]}')
return {"aggregate": ["B"]}
def b_2(state: State):
print(f'Adding "B_2" to {state["aggregate"]}')
return {"aggregate": ["B_2"]}
def c(state: State):
print(f'Adding "C" to {state["aggregate"]}')
return {"aggregate": ["C"]}
def c_2(state: State):
print(f'Adding "C_2" to {state["aggregate"]}')
return {"aggregate": ["C_2"]}
def d(state: State):
print(f'Adding "D" to {state["aggregate"]}')
return {"aggregate": ["D"]}
builder = StateGraph(State)
builder.add_node(a)
builder.add_node(b)
builder.add_node(b_2)
builder.add_node(c)
builder.add_node(d)
builder.add_edge(START, "a")
builder.add_edge("a", "b")
builder.add_edge("a", "c")
builder.add_edge("b", "b_2")
builder.add_edge("b_2", "d")
builder.add_edge("c", "d")
builder.add_edge("d", END)
graph = builder.compile()
from IPython.display import Image, display
display(Image(graph.get_graph().draw_mermaid_png()))
print(graph.invoke({"aggregate": []}))

Error Message and Stack Trace (if applicable)

Description

result:
Adding "A" to []

Adding "B" to ['A']

Adding "C" to ['A']

Adding "B_2" to ['A', 'B', 'C']

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

Adding "D" to ['A', 'B', 'C', 'B_2', 'D']

{'aggregate': ['A', 'B', 'C', 'B_2', 'D', 'D']}

Why did "D" execute twice?

System Info

System Information

OS: Linux
OS Version: #1 SMP PREEMPT_DYNAMIC Debian 6.1.148-1 (2025-08-26)
Python Version: 3.13.9 | packaged by Anaconda, Inc. | (main, Oct 21 2025, 19:16:10) [GCC 11.2.0]

Package Information

langchain_core: 1.0.0
langchain: 1.0.2
langsmith: 0.4.37
langchain_openai: 1.0.1
langgraph_api: 0.4.46
langgraph_cli: 0.4.4
langgraph_runtime_inmem: 0.14.1
langgraph_sdk: 0.2.9

Optional packages not installed

langserve

Other Dependencies

blockbuster: 1.5.25
claude-agent-sdk: Installed. No version info available.
click: 8.3.0
cloudpickle: 3.1.1
cryptography: 44.0.3
grpcio: 1.76.0
grpcio-tools: 1.76.0
httpx: 0.28.1
jsonpatch: 1.33
jsonschema-rs: 0.29.1
langchain-anthropic: Installed. No version info available.
langchain-aws: Installed. No version info available.
langchain-community: 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-perplexity: Installed. No version info available.
langchain-together: Installed. No version info available.
langchain-xai: Installed. No version info available.
langgraph: 1.0.1
langgraph-checkpoint: 3.0.0
langsmith-pyo3: Installed. No version info available.
openai: 2.6.0
openai-agents: Installed. No version info available.
opentelemetry-api: 1.38.0
opentelemetry-exporter-otlp-proto-http: 1.38.0
opentelemetry-sdk: 1.38.0
orjson: 3.11.3
packaging: 25.0
protobuf: 6.33.0
pydantic: 2.12.3
pyjwt: 2.10.1
pytest: Installed. No version info available.
python-dotenv: 1.1.1
pyyaml: 6.0.3
requests: 2.32.5
requests-toolbelt: 1.0.0
rich: Installed. No version info available.
sse-starlette: 2.1.3
starlette: 0.48.0
structlog: 25.4.0
tenacity: 9.1.2
tiktoken: 0.12.0
truststore: 0.10.4
typing-extensions: 4.15.0
uvicorn: 0.38.0
vcrpy: Installed. No version info available.
watchfiles: 1.1.1
zstandard: 0.25.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpendingawaiting review/confirmation by maintainer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions