> ## Documentation Index
> Fetch the complete documentation index at: https://cndoc-langchain.site/llms.txt
> Use this file to discover all available pages before exploring further.

# INVALID_CONCURRENT_GRAPH_UPDATE

一个 LangGraph [`StateGraph`](https://langchain-ai.github.io/langgraph/reference/graphs/#langgraph.graph.state.StateGraph) 从多个节点收到了对其状态的并发更新，而该状态属性不支持此操作。

这种情况可能发生的一种方式是，如果你在图中使用了[扇出](/oss/python/langgraph/use-graph-api#map-reduce-and-the-send-api)或其他并行执行，并且你定义了如下图：

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
class State(TypedDict):
    some_key: str  # [!code highlight]

def node(state: State):
    return {"some_key": "some_string_value"}

def other_node(state: State):
    return {"some_key": "some_string_value"}


builder = StateGraph(State)
builder.add_node(node)
builder.add_node(other_node)
builder.add_edge(START, "node")
builder.add_edge(START, "other_node")
graph = builder.compile()
```

如果上述图中的一个节点返回 `{ "some_key": "some_string_value" }`，这将用 `"some_string_value"` 覆盖 `"some_key"` 的状态值。
然而，如果例如在单个步骤的扇出中，多个节点为 `"some_key"` 返回了值，图将抛出此错误，因为对于如何更新内部状态存在不确定性。

要解决此问题，你可以定义一个组合多个值的归约器：

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
import operator
from typing import Annotated

class State(TypedDict):
    # The operator.add reducer fn makes this append-only  # [!code highlight]
    some_key: Annotated[list, operator.add]  # [!code highlight]
```

这将允许你定义处理从并行执行的多个节点返回的相同键的逻辑。

## 故障排除

以下内容可能有助于解决此错误：

* 如果你的图并行执行节点，请确保你已使用归约器定义了相关的状态键。

***

<div className="source-links">
  <Callout icon="terminal-2">
    [将这些文档连接](/use-these-docs)到 Claude、VSCode 等，通过 MCP 获取实时答案。
  </Callout>

  <Callout icon="edit">
    [在 GitHub 上编辑此页面](https://github.com/langchain-ai/docs/edit/main/src/oss/langgraph/errors/INVALID_CONCURRENT_GRAPH_UPDATE.mdx) 或 [提交问题](https://github.com/langchain-ai/docs/issues/new/choose)。
  </Callout>
</div>
