Agent variables
You may define reusable variables, that can be references in the agent’s prompt, welcome message or Tool parameters.
Defining variables
Variables are defined in ‘Variables’ field in the Agent configuration screen.
Use the NAME = VALUE format. Use multiple lines if you need to specify multiple variables.
For example:
customer_name = Lucy
api_key = 123456
Variables are automatically assigned a type: string, integer, float or boolean, based on the provided value. In the example above, customer_name variable is assigned string, and api_key is assigned an integer type.
Values of type string may be optionally enclosed in quotes, for example: sex = "male".
Alternatively, you may use JSON dictionary format to define agent variables, for example:
{"customer_name": "Lucy", "api_key": 123456}
Derived variables
You may also assign the result of an expression to a variable, using the double-parentheses syntax – NAME = ((expression)). The same syntax works in the Variables field of a Flow. This lets you derive a value from other variables or conversation data. Inside the parentheses, reference other variables by name (without curly brackets) and use any of the supported operators and functions – see Expression syntax.
For example, the following strips a leading + from the caller value, but only when it is present, and stores the result in a new my_caller variable:
my_caller = ((caller[1:] if caller.startswith('+') else caller))
Generated variables
Inside the double parentheses you may also call a generator function, which produces a new random value:
| Function | Value |
|---|---|
random_digits(count)
|
a string of count random digits (1–100), leading zeros included |
random_int(low, high)
|
a random whole number between low and high, both included |
uuid()
|
a new random UUID, for example 3f2b8c1e-9d4a-4e7b-b1c0-5a6d2e8f9b13 |
For example:
order_number = ((random_digits(10)))
call_ref = ((uuid()))
pin_label = (('PIN-' + random_digits(4)))
A generated variable keeps the value generated first for the whole conversation. The prompt, the init webhook and the tools all see the same value, and like any other variable it is propagated to sub-agents. A sub-agent or flow that defines a generated variable of the same name gets that same value too.
Generator functions are available in variable definitions and in Calculate node statements. They are not available in prompt conditions, logical conditions or transitions.
Using variables
To use variables in agent’s prompt / welcome message / tools configuration, specify the variable name enclosed in curly brackets.
For example:
You are parking reminder assistant.
You are calling {customer_name} to remind that her parking will expire soon.
Double brackets are also supported, for example {{customer_name}}.
Variables propagation
In multi-agent topologies variables are automatically propagated to sub-agents. Therefore, variables defined at the top-level agent can still be referenced by any sub-agent or corresponding tool.