Message deduplication is automatically handled by LangGraph's add_messages reducer because each message carries a unique ID. If the same message (with the same ID) is added again, it will replace the existing one rather than duplicate. For manual deduplication, you can use a custom reducer that checks for content equality before appending.
The default add_messages reducer already prevents duplication based on message IDs. When you create messages, LangChain assigns a random id if not provided. If you re-send the same message object (with the same ID), the reducer will replace it, not duplicate it. However, if you create two separate message objects with identical content but different IDs, they will both be added. To avoid this, you can either reuse the same message object or implement a custom reducer that checks content equality and skips duplicates.