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

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangChain
UniversalHubNodeLoadSerializableEncoder BackedFile SystemIn Memory
LangChain Core
AgentsCachesBaseDispatchWebManagerPromisesChat HistoryContextBaseLangsmithDocumentsEmbeddingsErrorsExample SelectorsIndexingBaseChat ModelsLlmsProfileLoadSerializableMemoryMessagesToolOutput ParsersOpenai FunctionsOpenai ToolsOutputsPrompt ValuesPromptsRetrieversDocument CompressorsRunnablesGraphSingletonsStoresStructured QueryToolsBaseConsoleLog StreamRun CollectorTracer LangchainStreamAsync CallerChunk ArrayContextEnvEvent Source ParseFormatFunction CallingHashJson PatchJson SchemaMathSsrfStreamTestingTiktokenTypesVectorstores
Text Splitters
MCP Adapters
Language
Theme
JavaScript@langchain/coremessagesToolMessageChunk
Class●Since v1.0

ToolMessageChunk

Represents a chunk of a tool message, which can be concatenated with other tool message chunks.

Copy
class ToolMessageChunk

Bases

BaseMessageChunk<TStructure, "tool">

Constructors

constructor
constructor

Properties

property
[MESSAGE_SYMBOL]: true
property
artifact: any

Artifact of the Tool execution which is not meant to be sent to the model.

Should only be specified if it is different from the message content, e.g. if only a subset of the full tool output is being passed as message content but the full output is needed in other parts of the code.

property
content: $InferToolOutputs<TStructure> extends TOutput ? [TOutput] extends [never] ? string | ContentBlock | Text[] : [unknown] extends [TOutput] ? string | ContentBlock | Text[] : string | ContentBlock | Text[] | TOutput : string | ContentBlock | Text[]

Array of content blocks that make up the message content

property
id: string

An optional identifier for the document.

Ideally this should be unique across the document collection and formatted as a UUID, but this will not be enforced.

property
lc_kwargs: SerializedFields
property
lc_namespace: string[]

A path to the module that contains the class, eg. ["langchain", "llms"] Usually should be the same as the entrypoint the class is exported from.

property
lc_serializable: boolean
property
name: string
property
response_metadata: NonNullable<BaseMessageFields<TStructure, TRole>["response_metadata"]>

Metadata about the message

property
status: "success" | "error"

The status of the server tool call

property
tool_call_id: string
property
type: "tool"
property
_printableFields: Record<string, unknown>
property
[toStringTag]: any
property
contentBlocks: Standard[]
property
lc_aliases: __type | undefined
property
lc_attributes: __type | undefined
property
lc_id: string[]
property
lc_secrets: __type | undefined
property
lc_serializable_keys: string[] | undefined
property
text: string

Block text.

deprecatedproperty
additional_kwargs: __type

Methods

method
_updateId
method
concat→ AIMessageChunk<TStructure>
method
toDict→ StoredMessage
method
toFormattedString→ string
method
toJSON→ Serialized
method
toJSONNotImplemented→ SerializedNotImplemented
method
isInstance→ obj is BaseMessage<T, MessageType> & AIMessage<T>

Type guard to check if an object is an AIMessage. Preserves the MessageStructure type parameter when called with a typed BaseMessage. When called with a typed BaseMessage, preserves the TStructure type

method
lc_name→ string

The name of the serializable. Override to provide an alias or to preserve the serialized module name in minified environments.

Implemented as a static method to support loading logic.

deprecatedmethod
_getType→ MessageType
deprecatedmethod
getType→ MessageType

Inherited fromBaseMessageChunk

Properties

Padditional_kwargs: __typePcontent: TStructure["outputVersion"] extends "v1" ? $InferMessageContentBlocks<TStructure, "ai">[] : string | ContentBlock | Text[]
—

Array of content blocks that make up the message content

Pid: string
—

An optional identifier for the document.

Plc_kwargs: SerializedFieldsPlc_namespace: ["langchain_core", "callbacks", string]
—

A path to the module that contains the class, eg. ["langchain", "llms"]

Plc_serializable: booleanPname: stringPresponse_metadata: NonNullable<BaseMessageFields<TStructure, TRole>["response_metadata"]>
—

Metadata about the message

Ptype: "function"P_printableFields: Record<string, unknown>PcontentBlocks: Standard[]Plc_aliases: __type | undefinedPlc_attributes: __type | undefinedPlc_id: string[]Plc_secrets: __type | undefinedPlc_serializable_keys: string[] | undefinedPtext: string
—

Block text.

Methods

M_getType→ MessageTypeM_updateIdMconcat→ AIMessageChunk<TStructure>MgetType→ MessageTypeMtoDict→ StoredMessageMtoFormattedString→ stringMtoJSON→ SerializedMtoJSONNotImplemented→ SerializedNotImplementedMisInstance→ obj is BaseMessage<T, MessageType> & AIMessage<T>
—

Type guard to check if an object is an AIMessage.

Mlc_name→ string
—

The name of the serializable. Override to provide an alias or

Inherited fromBaseMessage

Properties

Padditional_kwargs: __typePcontent: TStructure["outputVersion"] extends "v1" ? $InferMessageContentBlocks<TStructure, "ai">[] : string | ContentBlock | Text[]
—

Array of content blocks that make up the message content

Pid: string
—

An optional identifier for the document.

Plc_kwargs: SerializedFieldsPlc_namespace: ["langchain_core", "callbacks", string]
—

A path to the module that contains the class, eg. ["langchain", "llms"]

Plc_serializable: booleanPname: stringPresponse_metadata: NonNullable<BaseMessageFields<TStructure, TRole>["response_metadata"]>
—

Metadata about the message

Ptype: "function"P_printableFields: Record<string, unknown>PcontentBlocks: Standard[]Plc_aliases: __type | undefinedPlc_attributes: __type | undefinedPlc_id: string[]Plc_secrets: __type | undefinedPlc_serializable_keys: string[] | undefinedPtext: string
—

Block text.

Methods

M_getType→ MessageTypeM_updateIdMgetType→ MessageTypeMtoDict→ StoredMessageMtoFormattedString→ stringMtoJSON→ SerializedMtoJSONNotImplemented→ SerializedNotImplementedMisInstance→ obj is BaseMessage<T, MessageType> & AIMessage<T>
—

Type guard to check if an object is an AIMessage.

Mlc_name→ string
—

The name of the serializable. Override to provide an alias or

Inherited fromSerializable

Properties

Plc_kwargs: SerializedFieldsPlc_namespace: ["langchain_core", "callbacks", string]
—

A path to the module that contains the class, eg. ["langchain", "llms"]

Plc_serializable: booleanPlc_aliases: __type | undefinedPlc_attributes: __type | undefinedPlc_id: string[]Plc_secrets: __type | undefinedPlc_serializable_keys: string[] | undefined

Methods

MtoJSON→ SerializedMtoJSONNotImplemented→ SerializedNotImplementedMlc_name→ string
—

The name of the serializable. Override to provide an alias or

View source on GitHub