deepagents icon indicating copy to clipboard operation
deepagents copied to clipboard

INVALID_CONCURRENT_GRAPH_UPDATE Error for Todos State

Open dingkwang opened this issue 4 months ago • 2 comments

Problem

The deepagents library was encountering a INVALID_CONCURRENT_GRAPH_UPDATE error from LangGraph when multiple nodes in the agent's graph attempted to update the [todos] state key simultaneously. This error occurs because LangGraph's default behavior doesn't know how to resolve conflicts when parallel processes (e.g., tool calls) try to modify the same state property in the same step.

Error Details:

Error Message: At key 'todos': Can receive only one value per step. Use an Annotated key to handle multiple values. Root Cause: The [todos field in [DeepAgentState] was defined as [NotRequired[list[Todo]]], which doesn't specify a reducer function. When multiple tools or nodes (e.g., in a fan-out execution) update the [todos] list concurrently, LangGraph raises this error to prevent ambiguous state resolution. Impact: This prevented the agent from functioning correctly in scenarios involving parallel tool invocations, such as when the AI oncall bot processes multiple tasks or tools simultaneously. Solution To resolve this, I modified the [DeepAgentState] class in [state.py] to use an annotated type with a reducer:

Added Import: Imported the [operator] module to enable the use of [operator.add] as a reducer. Updated State Definition: Changed [todos: NotRequired[list[Todo]]] to [todos: Annotated[list[Todo], operator.add]]. This tells LangGraph to merge concurrent updates to the [todos] list by appending them (using [operator.add], rather than overwriting or erroring out. Changes Made:

File: [state.py] Added: [import operator] Modified: [todos: Annotated[list[Todo], operator.add]] Why This Fix Works [operator.add] for lists performs concatenation, ensuring that multiple updates to [todos] are combined into a single, coherent list. This aligns with LangGraph's recommended approach for handling concurrent state updates, as documented in their troubleshooting guide. The fix is minimal and targeted, preserving the existing behavior while enabling parallel execution.

dingkwang avatar Sep 08 '25 20:09 dingkwang

langgraph.errors.InvalidUpdateError: At key 'todos': Can receive only one value per step. Use an Annotated key to handle multiple values. For troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/INVALID_CONCURRENT_GRAPH_UPDATE During task with name 'tools' and id '4274ad5e-e728-952d-cc37-f07da861e719'

yasirali179 avatar Oct 14 '25 10:10 yasirali179

+1 on this problem - exact same problem as @yasirali179 . Using the vanilla example from the quickstart with the new gemini 3.0 model.

Anybody found a fix?

philikai avatar Nov 18 '25 21:11 philikai