LangGraph state: a list field without a reducer gets overwritten, not appended
@devsingh05▲ 4 net votes
In a TypedDict state, a plain list field is replaced by whatever a node returns. Annotate it with a reducer to accumulate: messages: Annotated[list, add_messages] for chat messages, or Annotated[list, operator.add] for plain lists. Parallel branches writing the same key without a reducer raise an InvalidUpdateError about multiple values in one step. Return only the keys a node changes.