How to use 'artifact' attribute in ToolMessage to output both text and image? #457

Closed
opened 2026-02-20 17:40:14 -05:00 by yindo · 0 comments
Owner

Originally created by @Cybertyann on GitHub (Feb 14, 2025).

Issue with current documentation:

In https://python.langchain.com/api_reference/core/messages/langchain_core.messages.tool.ToolMessage.html, it introduces the concept of 'arifact' and give a simple example:

from langchain_core.messages import ToolMessage
tool_output = {
"stdout": "From the graph we can see that the correlation between x and y is ...",
"stderr": None,
"artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."},
}

ToolMessage(
content=tool_output["stdout"],
artifact=tool_output,
tool_call_id='call_Jja7J89XsjrOLA5r!MEOW!SL',
)

,
if the tool function called by llm return an output likes tool_output = { "stdout": "From the graph we can see that the correlation between x and y is ...", "stderr": None, "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."}, }
, can the agent automatically return a toolmessage contains 'artifact'? Or how to use 'artifact' attribute in ToolMessage to output both text and image? There are few examples about how to get multimodal output. Thank you very much.

Idea or request for content:

No response

Originally created by @Cybertyann on GitHub (Feb 14, 2025). ### Issue with current documentation: In https://python.langchain.com/api_reference/core/messages/langchain_core.messages.tool.ToolMessage.html, it introduces the concept of 'arifact' and give a simple example: > from langchain_core.messages import ToolMessage >tool_output = { "stdout": "From the graph we can see that the correlation between x and y is ...", "stderr": None, "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."}, } >ToolMessage( content=tool_output["stdout"], artifact=tool_output, tool_call_id='call_Jja7J89XsjrOLA5r!MEOW!SL', ) , if the tool function called by llm return an output likes `tool_output = { "stdout": "From the graph we can see that the correlation between x and y is ...", "stderr": None, "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."}, }` , can the agent automatically return a toolmessage contains 'artifact'? Or how to use 'artifact' attribute in ToolMessage to output both text and image? There are few examples about how to get multimodal output. Thank you very much. ### Idea or request for content: _No response_
yindo closed this issue 2026-02-20 17:40:14 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#457