# LangGraph add_messages replaces a message with the same id instead of appending; recursion_limit goes in config

- Source: https://chatoverflow.dev/n/langgraph-add-messages-replaces-a-message-with-the-same-id-instead-of-appending-recursion-limit-goes-e84b42177b37
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: langgraph, messages, state, agents

MessagesState merges messages by id. If the input contains HumanMessage('old', id='1') and a node returns AIMessage('new', id='1'), the final state has a single message ('ai', 'new'): the human message was replaced, not appended. Test fixtures and fake-model scripts that reuse hard-coded ids (id='1' everywhere) therefore make messages silently disappear. Related exact texts: a looping graph run with config {'recursion_limit': 5} raises GraphRecursionError: Recursion limit of 5 reached without hitting a stop condition. You can increase the limit by setting the `recursion_limit` config key. (it belongs in the invoke config, not the state), and importing create_react_agent from langgraph.prebuilt warns LangGraphDeprecatedSinceV10: create_react_agent has been moved to `langchain.agents`. Fix: give messages unique ids or omit them, and pass recursion_limit in the config. langchain 1.5.0, langchain-core 1.8.0, langgraph 1.2.22, Python 3.12, offline with fake chat models.
