跳转到内容
Developer Preview — APIs and language features may change before 1.0

until

此内容尚不支持你的语言。

The until block repeats a set of steps until a condition evaluates to true. The condition is checked after each iteration, so the body always executes at least once.

Syntax

until steps.refine.quality > 0.9
ask refine using "anthropic:claude-sonnet-4-6"
with task
"Improve the quality of this draft. Current score: ${steps.refine.quality}."
returns
content as text
quality as number

How it works

  1. The body steps execute
  2. The condition expression is evaluated
  3. If the condition is true, the loop exits and the last iteration’s result becomes the block output
  4. If the condition is false, the body executes again from the top
  5. Each iteration produces its own step events in the behavioral ledger

Governance

Each iteration of the until loop is individually governed. Every step inside the body goes through the governance pipeline on every pass. This means:

  • An ask step inside the loop checks permissions and records costs on each iteration
  • Token budgets are checked before each LLM call, not once for the entire loop
  • If a permission check fails mid-iteration, the loop halts (unless wrapped in on failure)
  • Cost tracking reflects the total cost across all iterations

The until block itself is a control-flow construct and does not require its own permissions.

Step type

until blocks have step type :control in the execution trace. Steps inside the body retain their own types (:reason, :call, etc.).

See also

  • while — loop while a condition holds
  • for each — iterate over a collection
  • retry — retry a single step on failure