LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangChain
  • Browser
  • Universal
  • Hub
  • Node
  • Load
  • Serializable
  • Encoder Backed
  • File System
  • In Memory
  • Tools
LangChain Core
  • Agents
  • Caches
  • Base
  • Dispatch
  • Web
  • Manager
  • Promises
  • Chat History
  • Context
  • Base
  • Langsmith
  • Documents
  • Embeddings
  • Errors
  • Example Selectors
  • Indexing
  • Base
  • Chat Models
  • Compat
  • Event
  • Llms
  • Openai Completions Stream
  • Profile
  • Stream
  • Structured Output
  • Load
  • Serializable
  • Memory
  • Messages
  • Tool
  • Output Parsers
  • Openai Functions
  • Openai Tools
  • Outputs
  • Prompt Values
  • Prompts
  • Retrievers
  • Document Compressors
  • Runnables
  • Graph
  • Singletons
  • Stores
  • Structured Query
  • Testing
  • Tools
  • Base
  • Console
  • Log Stream
  • Run Collector
  • Tracer Langchain
  • Stream
  • Async Caller
  • Chunk Array
  • Context
  • Env
  • Event Source Parse
  • Format
  • Function Calling
  • Gateway
  • Hash
  • Json Patch
  • Json Schema
  • Math
  • Ssrf
  • Standard Schema
  • Stream
  • Testing
  • Tiktoken
  • Types
  • Uuid
  • Vectorstores
Text Splitters
MCP Adapters
⌘I

Chat LangChain

What can I help with?

Enter to sendĀ·Shift+Enter new line

Menu

LangChain
BrowserUniversalHubNodeLoadSerializableEncoder BackedFile SystemIn MemoryTools
LangChain Core
AgentsCachesBaseDispatchWebManagerPromisesChat HistoryContextBaseLangsmithDocumentsEmbeddingsErrorsExample SelectorsIndexingBaseChat ModelsCompatEventLlmsOpenai Completions StreamProfileStreamStructured OutputLoadSerializableMemoryMessagesToolOutput ParsersOpenai FunctionsOpenai ToolsOutputsPrompt ValuesPromptsRetrieversDocument CompressorsRunnablesGraphSingletonsStoresStructured QueryTestingToolsBaseConsoleLog StreamRun CollectorTracer LangchainStreamAsync CallerChunk ArrayContextEnvEvent Source ParseFormatFunction CallingGatewayHashJson PatchJson SchemaMathSsrfStandard SchemaStreamTestingTiktokenTypesUuidVectorstores
Text Splitters
MCP Adapters
Language
Theme
JavaScript@langchain/coremessagesaddNotificationMetadata
Functionā—Since v1.3

addNotificationMetadata

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.

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

Copy
addNotificationMetadata(message: HumanMessage, metadata: NotificationMetadata): HumanMessage

Parameters

NameTypeDescription
message*HumanMessage

The message to mark.

metadata*NotificationMetadata

The feature that added the message and its fields. data must be JSON-serializable.

Example

Copy
import { HumanMessage, addNotificationMetadata } from "@langchain/core/messages";

const message = addNotificationMetadata(
  new HumanMessage("Background task t_42 finished."),
  { source: "async_subagent", data: { task_id: "t_42", status: "success" } }
);
View source on GitHub