OpenAI Chat Completions Agent

Overview

The OpenAI Chat Completions Agent Snap accepts input containing an initial request contents, a list of tools, and parameters to invoke an Agent execution loop. The Snap handles the call to the OpenAI Chat Completions, consumes the result and call tools, then collect them accordingly until the model has no more tools to call.

Learn more about the Agent Snap in this developer blog.


Snap dialog with fieldsets expanded on the right side

  • Read-type Snap

Snap views

View Description Examples of upstream and downstream Snaps
Input This Snap has one document input view, typically carrying the input message for the OpenAI model.
Output This Snap has exactly two document output views. The first one outputs the full response from the model. The second one outputs the list of tools to call. It includes a JSON argument, whose value is a JSON object derived from converting the string-formatted argument of the model's response tool call.
Error

Error handling is a generic way to handle errors without losing data or failing the Snap execution. You can handle the errors that the Snap might encounter when running the pipeline by choosing one of the following options from the When errors occur list under the Views tab. The available options are:

  • Stop Pipeline Execution Stops the current pipeline execution when an error occurs.
  • Discard Error Data and Continue Ignores the error, discards that record, and continues with the remaining records.
  • Route Error Data to Error View Routes the error data to an error view without stopping the Snap execution.

Learn more about Error handling in Pipelines.

Snap settings

Legend:
  • Expression icon (): Allows using JavaScript syntax to access SnapLogic Expressions to set field values dynamically (if enabled). If disabled, you can provide a static value. Learn more.
  • SnapGPT (): Generates SnapLogic Expressions based on natural language using SnapGPT. Learn more.
  • Suggestion icon (): Populates a list of values dynamically based on your Snap configuration. You can select only one attribute at a time using the icon. Type into the field if it supports a comma-separated list of values.
  • Upload : Uploads files. Learn more.
Learn more about the icons in the Snap settings dialog.
Field / Field set Type Description
Label String

Required. Specify a unique name for the Snap. Modify this to be more appropriate, especially if more than one of the same Snaps is in the pipeline.

Default value: OpenAI Chat Completions Agent

Example: Invoke gpt-4 model for sentiment analysis

Visualize agent flow String

Launch the Agent Visualizer UI.

Default value: N/A

Model name String/Expression/ Suggestion Required. Specify the name of the OpenAI model you want to use, such as gpt-4o or gpt-4o-mini.

Default value: N/A

Example: gpt-4o

Message payload String/Expression Required. Enter the message payload that will be processed by the model. This payload typically includes input messages in JSON format. The message is an array passed from the input document and obtained through an expression.
Important: Here are the typical scenarios of how the tool calling Snap processes different types of message lists in the input document:
  • If a message does not contain sl_role, the Snap sends the message to the model without any modifications.
  • If a message does not contain sl_role but has sl_type in any item of the content list, the Snap sends without any modifications; however it also displays a lint warning.
  • 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.
  • If the sl_role is SYSTEM, USER or ASSISTANT and if the content is multimodal content generated by Multimodal Content Generator Snap, the Snap reformats the content as the model requires.
  • 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.
Learn more about how the tool calling Snap parses the message payload.

Default value: N/A

Example: $inputMessage

Tool payload String/Expression Required. Enter the tool payload that defines the tools (name, description, parameters, etc.) the model can choose to call.
Note: The model cannot directly call tools. It can only suggest, based on the tool definition, which tools are required to respond to the user's original prompt. The actual tool invocation is the user's responsibility.

Default value: N/A

Example: $specifiedTools

Output Handling Checkbox/Expression

Select to store the output.

Default value: Deselected.

Store Checkbox/Expression

Indicate whether to store or not store the output of the chat completion request.

Default status: Deselected

Agent execution configuration

Modify the limitation of the Agent execution.

Iteration limit Integer/Expression

Required. The maximum iterations an agent should run.

Default: 10

Example: 10
Monitor tool calls Checkbox

Monitor tool call parameters in pipeline statistics.

Default status: Selected

Pool size Integer/Expression

Required. The number of threads for parallel tool execution.

Default value:1

Example: 1
Reuse tool pipeline Checkbox

Reuse the tool pipeline for tool execution.

Default status: Deselected

Advanced tool configuration

Modify the tool call settings to guide the model responses and optimize output processing.

Tool choice Dropdown list/Expression

Controls which (if any) tool is called by the model.

  • REQUIRED
  • SPECIFY A FUNCTION
  • AUTO
  • NONE
Default value: AUTO

Example: AUTO

Function name String/Expression

Required. The name of the function to force the model to call.

Default value: N/A

Example: get_weather
Parallel tool call Checkbox/Expression

Select this checkbox to enable parallel tool calling.

Default status: Selected

Model parameters Configure the parameters to tune the model runtime.
Reasoning effort Dropdown list/Expression

Select the level of constraint for a reasoning model.

Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.

  • low
  • medium
  • high

Enabled if the mode is a reasoning model or an expression.

Default value: medium

Maximum tokensInteger/Expression

Specify the maximum number of tokens to be used to generate the chat completions result, including tokens used for reasoning. If left blank, the default value of the endpoint is used.

Default value: N/A

Example: 50

Temperature Decimal/Expression

Specify the sampling temperature to use a decimal value between 0 and 1. If left blank, the default value of the endpoint is used.

Default value: N/A

Example: 0.2

Top P Decimal/Expression

Specify the nucleus sampling value, a decimal value between 0 and 1. If left blank, the default value of the endpoint is used.

Default value: N/A

Example: 0.2

Stop sequences String/Expression

Specify a sequence of texts or tokens to stop the model from generating further output. Learn more.

Note:
  • You can configure up to four stop sequences when generating the text. These stop sequences tell the model to halt further text generation if any of the specified sequences are encountered.
  • The returned text does not contain the stop sequence.

Default value: N/A

Example: pay, ["amazing"], ["September", "paycheck"]
Advanced prompt configuration Configure the prompt settings to guide the model responses and optimize output processing.
Structured outputs String/Expression

Enter the schema or expression to ensures that the model always returns outputs that match your defined JSON Schema.

Default value: N/A

Example: $response_format.json_schema

Important:

Only the following models support structured outputs for JSON mode:

  • o3-mini-2025-1-31 and later
  • o1-2024-12-17 and later
  • gpt-4o-mini-2024-07-18 and later
  • gpt-4o-2024-08-06 and later
JSON modeCheckbox/Expression Select this checkbox to enable the model to generate strings that can be parsed into valid JSON objects. The output includes the json_output field that contains the parsed JSON object, encapsulating the data.
Snap execution Dropdown list
Choose one of the three modes in which the Snap executes. Available options are:
  • Validate & Execute: Performs limited execution of the Snap and generates a data preview during pipeline validation. Subsequently, performs full execution of the Snap (unlimited records) during pipeline runtime.
  • Execute only: Performs full execution of the Snap during pipeline execution without generating preview data.
  • Disabled: Disables the Snap and all Snaps that are downstream from it.

Default value: Validate & Execute

Example: Execute only