コンテンツにスキップ
Developer Preview — APIs and language features may change before 1.0

match

このコンテンツはまだ日本語訳がありません。

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

  1. The match expression evaluates the target value (e.g., steps.classify.action)
  2. Each arm compares the result against a literal value using =>
  3. The first arm that matches executes its body
  4. If no arm matches and no default is provided, the step returns null
  5. 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