Use variables to store and reuse values in your agent’s reasoning and control how an agent makes decisions. For example, when you assign a variable to an action input, your agent can use only the assigned variable to fill the value of the input.
Required Editions
| Available in: Lightning Experience |
| Available in: Enterprise, Performance, Unlimited, and Developer Editions. Required add-on licenses vary by agent type. |
| User Permissions Needed | |
|---|---|
| To create a variable: | Manage AI Agents AND the required permissions for your agent type |
- From the App Launcher, enter Agent, and then select the Agentforce Studio app.
- On the Agents tab, click the name of your agent.
- On the Explorer panel, click Variables.
-
On the Variables page, click New.
- To create a custom variable, click Create Custom Variable. In the New Variable window, define the variable's settings. By default, variables can only be set in the agent. To set the value of a variable with an API, select Enable API write access.
- To add a context variable that's mapped to a Messaging Session object field, click Add Messaging Session Variable. Select the variables that you want to add and then click Add to Agent.
To create a variable that's set to an action output, select an action in the Actions Available For Reasoning section of a subagent. Next to an action output, click Select Variable and then select Create a variable. In the New Variable window, define the variable's settings.
By default, action inputs are agent populated. To assign a specific variable to an action input, select an action in the Actions Available For Reasoning section of a subagent. Then, next to an action input, click Select Variable.
To use a variable in subagent instructions, use this
format in natural language prompts: {!@variables.VariableName}. And
use this format in logical expressions: @variables.VariableName.