Where conditions appear
Memory references
Every memory reference has three segments:<namespace> is a skill id or the literal project. <entry_name> is the
bare field name as declared in memory.yml.
skills/card_replace/ with name: Card Replace is referenced as
session.card_replace.<entry>.
Operators
Comparisons chain, so
session.a.x < session.a.y < 10 behaves as it does in
Python. These are the operators the expression parser accepts.
To test membership in a set, write it as a disjunction:
Truthiness
An unset memory entry reads asNone, and the whole expression is coerced with
bool(). A bare reference is therefore a presence test:
True, and
False. Compare explicitly to tell them apart:
0, 0.0, "", and [] are falsy. For a numeric entry that may legitimately
be zero, compare against None rather than relying on truthiness.Which entries you may reference
A condition on a skill can read:- that skill’s own
publicandprivatefields - other skills’
publicfields - project fields, declared in the root
memory.yml
access.deny_read. These are the same
rules the runtime applies when it assembles memory for a turn, so a reference
that passes validation resolves at runtime.
Writing long conditions in YAML
Conditions are often longer than a line. Use a folded scalar (>), which joins
the lines with spaces into a single-line expression:
- Quote or fold a condition containing
:followed by a space, so YAML reads it as a string rather than a mapping. - Use single quotes for string literals inside a condition, so the whole
expression can sit in double quotes:
"session.card_replace.replacement_reason == 'stolen'".
Gates fail closed
Every condition guards access to something: a skill, a tool, a paragraph. When a condition does not hold, the thing it guards is withheld:
Withholding is also the outcome when a condition cannot be evaluated at all.
This is deliberate: offering a tool and then refusing the call would waste a
turn, so the safe direction is to keep it hidden.
What rasa train checks
Prose if: conditions are verified before packaging, so branching errors surface
at build time rather than mid-conversation:
The last one is the useful one: it catches a mistyped entry name or a reference
to a field the active skill has no access to.
The Inspector’s tools panel shows the current gate result for every declared
tool, which is the quickest way to confirm a
requires: expression behaves the
way you intended.
Worked examples
Inlinerequires: patterns (same shape as tool constraints in a banking card-replace skill):
else: provides the fallback:
See also
skill.mdreference: where each condition site is declaredmemory.ymlreference: declaring the entries conditions read- Tool Constraints: gating tools with
requires: - Scoped Instructions:
if:markers in prose