Parallel branches in LangGraph share graph state, so overlapping writes need a merge rule. A reducer fixes concurrent state update errors when several branches must contribute values to the same key.
The relevant failure is InvalidUpdateError with INVALID_CONCURRENT_GRAPH_UPDATE and the message “Can receive only one value per step”. The exception names the affected state key, whose default update behavior cannot combine multiple writes in the same graph step.
A small graph with two deterministic nodes isolates state merging from model and network failures. It requires a Python environment with LangGraph installed and runs without a model or API key.
Steps to fix concurrent state update errors in LangGraph:
- Create parallel_update.py with the initial state schema in your text editor.
- parallel_update.py
from typing import TypedDict from langgraph.graph import END, START, StateGraph class State(TypedDict): results: list[str]
- Add two branch functions immediately below the State class in parallel_update.py.
def branch_a(state: State): return {"results": ["branch-a"]} def branch_b(state: State): return {"results": ["branch-b"]}
Each function returns only its new contribution. Returning the full input state from a parallel node can also write unrelated keys that the node did not intend to change.
- Append the parallel graph definition at the end of parallel_update.py.
builder = StateGraph(State) builder.add_node("branch_a", branch_a) builder.add_node("branch_b", branch_b) builder.add_edge(START, "branch_a") builder.add_edge(START, "branch_b") builder.add_edge("branch_a", END) builder.add_edge("branch_b", END) graph = builder.compile() print(graph.invoke({"results": []}))
Both edges from START activate their destinations in the same graph step. The initial empty list supplies no branch results.
- Save parallel_update.py in your project directory.
- Run parallel_update.py with your project's Python interpreter to reproduce the failure.
$ python parallel_update.py Traceback (most recent call last): ##### snipped ##### langgraph.errors.InvalidUpdateError: At key 'results': Can receive only one value per step. Use an Annotated key to handle multiple values. For troubleshooting, visit: https://docs.langchain.com/oss/python/langgraph/errors/INVALID_CONCURRENT_GRAPH_UPDATE
- Locate the conflicting results writes in the two branch functions.
Both functions return a list for results, but the schema declares only list[str]. A list type alone does not enable merging. In an existing failing graph, the exception's key identifies which schema field and node return dictionaries need inspection.
- Replace the imports and State declaration at the top of parallel_update.py with a list reducer.
import operator from typing import Annotated, TypedDict from langgraph.graph import END, START, StateGraph class State(TypedDict): results: Annotated[list[str], operator.add]
operator.add concatenates lists, preserving both contributions. Each node must return a list of new items for this key, rather than a scalar or the accumulated list. The two branch functions and graph definition remain unchanged. For a scalar field, the reducer must implement the intended combination for that type; list concatenation is appropriate only when the state and updates are lists.
- Save the reducer change in parallel_update.py.
- Rerun parallel_update.py to confirm that results contains both branch contributions without the exception.
$ python parallel_update.py {'results': ['branch-a', 'branch-b']}The script rebuilds and recompiles the graph using the amended schema before invoking it. Both branch-a and branch-b must appear exactly once; list order is not the success criterion for parallel branches.