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.
import { Annotation, StateGraph, Overwrite } from "@langchain/langgraph";
const State = Annotation.Root({
messages: Annotation<string[]>({
reducer: (a, b) => a.concat(b),
default: () => [],
}),
});
const replaceMessages = (_state: typeof State.State) => {
return { messages: new Overwrite(["replacement"]) };
};