Variables are used to store and retrieve runtime conversation data. This enables agents to remember information across conversational turns, leading to more contextual interactions.
Variable data
Variables have the following data:
- Name: Variable name using snake case
- Type: Variable type:
- Text: String values
- Number: Numeric values
- Yes/No: Boolean values
- Custom Object: You provide a schema for the object
- List: List of variables. Provide values as a comma delimited list.
- Default value: Default value for the variable
- Description: Optional description of the variable
Variable references in instructions
To reference a variable by name in your instructions,
use braces: {variable_name}.
Resolving variables
When generating a prompt for the model, CX Agent Studio replaces variable references with the actual runtime values.
Updating variable values
The agent itself cannot update the value of a variable, but tools and callbacks can update variable values.
Agent variables use the
ADK context state,
which can be used to update variables.
A global variable called context is available to use in your Python tool code.
For example,
you can use the following statement in a Python tool to update a variable
using ADK features:
context.state["variable_name"] = value
Finding variable uses
To find variable uses:
- Open the variable panel
- Click the target icon. Instructions and tools that use the variable are highlighted on the builder.