langchain-ai/langgraph · error · ValueError

Message ID is required

Error message

Message ID is required

What it means

Raised by write_message when the message to stream has no ID. Streaming to the messages/messages-tuple mode requires stable IDs so clients can dedupe and patch messages; auto-generated None IDs are rejected.

Solutions

  1. Assign an explicit ID, e.g. {'role': 'user', 'content': ..., 'id': str(uuid4())}
  2. Use create_model messageId or langchain message constructors that generate IDs
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at libs/langgraph/langgraph/graph/message.py:414 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of langchain-ai/langgraph@38031739e5 (2026-08-26). Data as JSON: /api/errors/c6d2a04574d29a14. Report an issue: GitHub.

Appendix: source

Thrown at libs/langgraph/langgraph/graph/message.py:414

) -> AnyMessage:
    """Write a message manually to the `messages` / `messages-tuple` stream mode.

    Will automatically write to the channel specified in the `state_key` unless `state_key` is `None`.
    """

    from langchain_core.callbacks.base import (
        BaseCallbackHandler,
        BaseCallbackManager,
    )

    from langgraph.config import get_config
    from langgraph.pregel._messages import StreamMessagesHandler

    config = get_config()
    message = next(x for x in convert_to_messages([message]))

    if message.id is None:
        raise ValueError("Message ID is required")

    if isinstance(config["callbacks"], BaseCallbackManager):
        manager = config["callbacks"]
        handlers = manager.handlers
    elif isinstance(config["callbacks"], list) and all(
        isinstance(x, BaseCallbackHandler) for x in config["callbacks"]
    ):
        handlers = config["callbacks"]

    if stream_handler := next(
        (x for x in handlers if isinstance(x, StreamMessagesHandler)), None
    ):
        metadata = config["metadata"]
        message_meta = (
            tuple(cast(str, metadata["langgraph_checkpoint_ns"]).split(NS_SEP)),
            metadata,
        )
        stream_handler._emit(message_meta, message, dedupe=False)

View on GitHub (pinned to 38031739e5)