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.
addNotificationMetadata(message: HumanMessage, metadata: NotificationMetadata): HumanMessage| Name | Type | Description |
|---|---|---|
message* | HumanMessage | The message to mark. |
metadata* | NotificationMetadata | The feature that added the message and its fields. |
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" } }
);