Skip to main content
A condition is a single-line expression string, evaluated against the current memory values whenever the runtime needs it. The same grammar is used everywhere a condition appears.

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.
The namespace is the skill’s directory name, which is also its catalog id. A skill in 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 as None, and the whole expression is coerced with bool(). A bare reference is therefore a presence test:
This matters for a boolean with three meaningful states: unset, 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 public and private fields
  • other skills’ public fields
  • project fields, declared in the root memory.yml
minus anything listed in the skill’s 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:
Two quoting rules:
  • 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

Inline requires: patterns (same shape as tool constraints in a banking card-replace skill):
Prose scoping:
Branch routing inside an ordered block, where else: provides the fallback:

See also