[PR #6286] feat(langgraph): add Overwrite to bypass reducer #4951

Closed
opened 2026-02-20 17:51:00 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langchain-ai/langgraph/pull/6286

State: closed
Merged: Yes


See https://github.com/langchain-ai/langgraph/pull/6277

Adds langgraph.types.Overwrite, a deterministic way to bypass a reducer. When encountering a value wrapped with Overwrite, BinaryOperatorAggregate overwrites the channel value.

image

If either node_b or node_c overwrite (but not both), then at END the channel is equal to the value node_b or node_c wrote. Order of execution doesn't matter because once an Overwrite value is encountered, regular values are ignored (self.operator is not called for the rest of the update)

If multiple nodes overwrite in the same superstep then InvalidUpdateError is thrown

Usage

from langgraph.types import Overwrite

def node_b(state:State):
    return {"messages": Overwrite(["b"])}

or

def node_b(state:State):
    return {"messages": {"__overwrite__": ["b"]}}
**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/6286 **State:** closed **Merged:** Yes --- See https://github.com/langchain-ai/langgraph/pull/6277 Adds langgraph.types.Overwrite, a deterministic way to bypass a reducer. When encountering a value wrapped with Overwrite, BinaryOperatorAggregate overwrites the channel value. <img width="227" height="329" alt="image" src="https://github.com/user-attachments/assets/f2136117-9aa3-4246-863d-d5df0e7d1df1" /> If either node_b or node_c overwrite (but not both), then at END the channel is equal to the value node_b or node_c wrote. Order of execution doesn't matter because once an Overwrite value is encountered, regular values are ignored (self.operator is not called for the rest of the update) If multiple nodes overwrite in the same superstep then InvalidUpdateError is thrown Usage ```python from langgraph.types import Overwrite def node_b(state:State): return {"messages": Overwrite(["b"])} ``` or ``` python def node_b(state:State): return {"messages": {"__overwrite__": ["b"]}} ```
yindo added the pull-request label 2026-02-20 17:51:00 -05:00
yindo closed this issue 2026-02-20 17:51:00 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#4951