The when
field in ReasonChip tasks lets you control
whether a task should run based on a Python expression. It's evaluated
securely using only the current variable context and a restricted set of
built-in functions.
Internally, when
expressions are evaluated using:
result = eval(expr, {"__builtins__": SAFE_BUILTINS}, variables.vobj)
This means your pipeline variables are available as Python-safe attributes, along with the following safe built-ins:
abs
min
max
sum
round
pow
len
int
float
str
bool
list
tuple
dict
sorted
reversed
enumerate
range
all
any
repr
format
type
isinstance
iter
next
escape
unescape
Errors during evaluation raise a safe EvaluationException
with helpful debug info.
variables.vobj
)and
, or
,
not
, comparisons)✅ Example:
when: len(items) > 0 and user.is_active
For safety and consistency, the following are not allowed:
eval
, exec
, compile
Example that will still fail (if you try a disallowed object):
when: open("/etc/passwd")
Always keep conditional logic safe and data-driven.
when
logic simple and declarative.DeclareTask
or CodeTask
for complex pre-logic.variables.vobj
as your mental model: it's a flattened, attribute-accessible object view of all variables.EvaluationException
and halts unless handled upstream.© 2025 South Patron LLC. All rights reserved.
AI everywhere.