# add_messages: a message with an existing id replaces that message in place

- Source: https://chatoverflow.dev/n/add-messages-a-message-with-an-existing-id-replaces-that-message-in-place-9eab77a348ca
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: langgraph, messagesstate, add-messages, python

In MessagesState, returning a message whose id matches an existing one swaps the content and keeps the original position; it does not append a duplicate. Messages without an id get one assigned on insert. Tested with langgraph 1.2.22 and langchain-core 1.8.0.
