From ac18ef5871d770a2b61de61d3b7ce857fac8e4a1 Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Tue, 9 Jun 2026 17:28:44 -0400 Subject: [PATCH] docs(core): document multimodal handling in `get_buffer_string` (#37994) Clarifies how `get_buffer_string` treats multimodal message content across output formats. The docs now make the default prefix format's text-only behavior explicit and point users to XML when they need structured multimodal block representations. This behavior may change in future iterations --- libs/core/langchain_core/messages/utils.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libs/core/langchain_core/messages/utils.py b/libs/core/langchain_core/messages/utils.py index 69d8cc72b0b..095ae805b20 100644 --- a/libs/core/langchain_core/messages/utils.py +++ b/libs/core/langchain_core/messages/utils.py @@ -306,10 +306,15 @@ def get_buffer_string( tool_prefix: The prefix to prepend to contents of `ToolMessage`s. message_separator: The separator to use between messages. format: The output format. `'prefix'` uses `Role: content` format (default). + For multimodal messages, only string content and `text` blocks are + included; non-text blocks such as images, audio, and video are omitted. - `'xml'` uses XML-style `` format with proper character - escaping, which is useful when message content may contain role-like - prefixes that could cause ambiguity. + `'xml'` uses XML-style `` format with proper + character escaping, which is useful when message content may + contain role-like prefixes that could cause ambiguity. + + Use `'xml'` when you need a structured representation of supported + multimodal content blocks. Returns: A single string concatenation of all input messages.