LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    โŒ˜I

    Chat LangChain

    What can I help with?

    Enter to sendยทShift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-coremessagesnotificationadd_notification_metadata
    Functionโ—Since v1.7

    add_notification_metadata

    Copy
    add_notification_metadata(
      message: HumanMessage,
      *,
      source: str,
      data: dict[str
    View source on GitHub
    ,
    Any
    ]
    |
    None
    =
    None
    )
    ->
    HumanMessage

    Parameters

    NameTypeDescription
    message*HumanMessage

    The message to mark.

    source*str

    The feature that added the message.

    datadict[str, Any] | None
    Default:None

    Return a copy of message marked as added by the agent harness.

    Use it for a human message the user didn't type, such as a background task update or a conversation summary. It sets additional_kwargs["lc_source"] and, when data is given, additional_kwargs["lc_data"]. Any earlier lc_source and lc_data are removed first. LangChain's chat model integrations don't send these keys to the model.

    It doesn't change the content. Write the content the model reads yourself.

    Anyone who can send input to a thread can set these keys. Don't use them to decide whether to trust a message.

    merge_message_runs and chunk addition join a notification with adjacent human messages; the merged message keeps the metadata and concatenates lc_source.

    Example:

    from langchain_core.messages import HumanMessage, add_notification_metadata
    
    message = add_notification_metadata(
        HumanMessage("Background task t_42 finished."),
        source="async_subagent",
        data={"task_id": "t_42", "status": "success"},
    )

    The feature's fields. Must be JSON-serializable.