match
Ce contenu n’est pas encore disponible dans votre langue.
The match expression dispatches to different branches based on the value of an expression. It is used inside decide steps for multi-way branching where each branch corresponds to a specific value.
Syntax
decide route_action match steps.classify.action "create_task" => compute result {action: "create", queue: "tasks"} "escalate" => compute result {action: "escalate", queue: "urgent"} "file_only" => compute result {action: "file", queue: "archive"}How it works
- The
matchexpression evaluates the target value (e.g.,steps.classify.action) - Each arm compares the result against a literal value using
=> - The first arm that matches executes its body
- If no arm matches and no default is provided, the step returns
null - The result of the matched branch becomes the step’s output
Governance
match is pure control flow inside a decide step. It evaluates conditions and routes execution but performs no I/O itself. The branch decision is recorded as a first-class step event in the behavioral ledger, including the matched value and the selected arm. Steps inside match arms inherit normal governance; an ask step inside a match arm still requires reason capability.
Step type
match is used within decide steps, which have step type :decide in the execution trace and ledger events.
See also
- decide — conditional branching with when/otherwise
- compute — pure computation with ternary expressions
- ask … using — when the decision requires LLM judgment