Parse message list

In the tool-calling pipeline, message payloads sent to the model can encompass a wide range of content, including the original prompt generated by you, the model's prior responses, results from tool calls run by you, and multimodal content. Each message may originate from different Snaps, such as Prompt Generators, Multimodal Content Generators, Function Generators, or Function Result Generators. Additionally, messages may include custom data. This article illustrates how the tool-calling Snaps parse message payloads to help you understand how to construct valid message payloads and what information is transmitted to the model.

Here are the typical scenarios of how the tool calling Snap processes the message list of the input document:

Scenarios Images
If a message does not contain sl_role, the tool calling Snap sends the message to the model without any modifications.
Create and Run Thread Without sl_role

If a message does not contain sl_role but contains sl_type in any item of the content list, the Snap sends without any modifications; however it also displays a lint warning.
Create and Run Threadcontains sl_type

If the sl_role is SYSTEM, USER or ASSISTANT, the Snap parses the sl_role, name and the content fields. All the other fields are filtered out and are not sent to the model; however, they are displayed in the output document.
Create and Run Thread sl_role is user

If the sl_role is SYSTEM, USER or ASSISTANT and if the content is multimodal content generated by the Multimodal Content Generator Snap, the Snap reformats the content as the model requires.
Create and Run Thread Reformatted content

If the sl_role is TOOL, which is a function result generated by Function Result Generator Snap, the Snap parses the sl_role, name and the content fields. All the other fields are filtered out and are not sent to the model; however they are displayed in the output document.
Create and Run Thread sl_role is TOOL