- Conditionally make other Functions available
- Set conditional logic in prompt instructions
- Compare values across different parts of your GenerativeAgent workflow
- Control Function exposure based on data from previous function calls.
- Toggle conditional instructions in your Task s prompt depending on returned data
- Extract and transform values without hard‐coding logic into prompts or code

Define a Reference Variable
To create a reference variable in the GenerativeAgent UI:- Navigate to the Function’s settings
- Find the “Reference vars (Optional)” section and click “Add”
- Configure the following fields:
- Name
- Response Keypath
- Transform Expression (Optional)
Name
This is the identifier you’ll use to reference this variable in Jinja expressions.Response Keypath
This is the JSON path where the data will be extracted from, using dot notation.Transform Expression (Optional)
This is a Jinja expression to transform the extracted value. Common patterns include:Reference variable names are not unique across the entire system.If more than one Function defines a reference variable with the same name, whichever Function is called last may overwrite a variable’s value.Reference variables are also used at runtime, meaning GenerativeAgent extracts the specified response data from each API call that returns successfully and updates the variable accordingly.
Example Condition
The following example calls a Condition on aCheckRoomAvailability
Function.
- Suppose a Reference Variable named
rooms_available
and defined with:- Response Keypath:
response.available_rooms
- Transform:
val is not none and val|length > 0
- Response Keypath:
- The
rooms_available
variable will be True whenever the returned list has a length greater than zero. You can then write: - In a Function’s conditions (to make a function available for use, conditioned on the reference variable):
- In Task instructions using Jinja:
Tips and Best Practice
Here are some tips to enhance your experience with Reference Variables:Prefix Variables
Prefix Variables
Consider prefixing variable names to avoid clashes if multiple teams define references.Example:
user_is_compliant
vs. is_compliant
Short-circuit logic
Short-circuit logic
Use short-circuit logic in transforms to avoid “NoneType cannot have length” errorsExample
val is not none and val|length > 0
Functions consideration
Functions consideration
Keep in mind that if multiple Functions define the same reference variable name, one may overwrite the other depending on the call order.