LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Graphs
    • Functional API
    • Pregel
    • Checkpointing
    • Storage
    • Caching
    • Types
    • Runtime
    • Config
    • Errors
    • Constants
    • Channels
    • Agents
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewGraphsFunctional APIPregelCheckpointingStorageCachingTypesRuntimeConfigErrorsConstantsChannelsAgents
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    Language
    Theme
    Pythonlanggraphchannelsbinop
    Moduleā—Since v0.1

    binop

    Attributes

    Functions

    Classes

    View source on GitHub
    attribute
    OVERWRITE
    attribute
    MISSING
    attribute
    Value
    function
    create_error_message
    class
    BaseChannel
    class
    ErrorCode
    class
    InvalidUpdateError
    class
    Overwrite
    class
    BinaryOperatorAggregate

    Unset sentinel value.

    Base class for all channels.

    Raised when attempting to update a channel with an invalid set of updates.

    Troubleshooting guides:

    • INVALID_CONCURRENT_GRAPH_UPDATE
    • INVALID_GRAPH_NODE_RETURN_VALUE

    Bypass a reducer and write the wrapped value directly to a BinaryOperatorAggregate channel.

    Receiving multiple Overwrite values for the same channel in a single super-step will raise an InvalidUpdateError.

    Example
    from typing import Annotated
    import operator
    from langgraph.graph import StateGraph
    from langgraph.types import Overwrite
    
    class State(TypedDict):
        messages: Annotated[list, operator.add]
    
    def node_a(state: TypedDict):
        # Normal update: uses the reducer (operator.add)
        return {"messages": ["a"]}
    
    def node_b(state: State):
        # Overwrite: bypasses the reducer and replaces the entire value
        return {"messages": Overwrite(value=["b"])}
    
    builder = StateGraph(State)
    builder.add_node("node_a", node_a)
    builder.add_node("node_b", node_b)
    builder.set_entry_point("node_a")
    builder.add_edge("node_a", "node_b")
    graph = builder.compile()
    
    # Without Overwrite in node_b, messages would be ["START", "a", "b"]
    # With Overwrite, messages is just ["b"]
    result = graph.invoke({"messages": ["START"]})
    assert result == {"messages": ["b"]}

    Stores the result of applying a binary operator to the current value and each new value.

    import operator
    
    total = Channels.BinaryOperatorAggregate(int, operator.add)