- Reasoning mode: The agent has no
FLOW:section, and the runtime decides how to pursue the goal. - Scripted flow mode: The agent has a
FLOW:section and follows authored steps, actions, guards, and transitions.
DELEGATE, HANDOFF, and ESCALATE. Every flow step must declare REASONING: true or REASONING: false.
Minimal scripted flow example
Flow structure and execution
FLOW
FLOW: defines the scripted state machine. Steps are named blocks. A step can transition to any other step, which allows linear flows, branches, retries, loops, and terminal paths.
Use it for:
- Fixed process ordering.
- Deterministic tool execution.
- Compliance or audit requirements.
- High-volume workflows where unnecessary LLM turns should be avoided.
REASONING
REASONING controls whether a step is deterministic or LLM-assisted:
false for explicit actions and boolean conditions. Use true when the step needs flexible interpretation, tool selection, or reasoning that can’t be represented as deterministic expressions.
Reasoning-step controls include GOAL, AVAILABLE_TOOLS, EXIT_WHEN, MAX_TURNS, and STEP_CONSTRAINTS.
Learn more: Per-step REASONING toggle.
WHEN
WHEN is an entry guard. The step runs only when its condition is true.
MAX_ATTEMPTS and ON_EXHAUSTED
MAX_ATTEMPTS limits retries for a step. ON_EXHAUSTED routes to a recovery step once the limit is reached.
THEN
THEN is the normal next transition.
THEN can point to a named step or a terminal action such as COMPLETE.
Learn more: THEN / ON_FAIL.
User interaction constructs
RESPOND
RESPOND sends text to the user. Responses support {{variable}} interpolation and multiline pipe blocks. The FLOW reference sometimes labels this concept “SAY / RESPOND” — RESPOND: is the canonical flow action used in ABL examples.
PRESENT
PRESENT shows context before a GATHER operation.
GATHER
GATHER collects one or more fields from the user. It can specify type, required status, prompt, defaults, validation, extraction strategy, and correction behavior.
CHECK or CONSTRAINTS for cross-field rules.
Learn more: GATHER for the full field-type and validation reference, or GATHER in flow steps for flow-specific syntax.
State and data constructs
SET
SET assigns values to session variables. The right-hand side can be a literal, variable, dotted result path, or built-in expression.
SET for normalization, derived values, flags, counters, tool-result extraction, and workflow IDs.
Learn more: SET.
CLEAR
CLEAR removes variables from session state. This is useful when the user changes an earlier choice and dependent values must be recollected.
TRANSFORM
TRANSFORM applies a declarative array pipeline. The stages are FILTER, MAP, SORT_BY, and LIMIT.
TRANSFORM for search results, transaction lists, catalog filtering, reporting data, and safe presentation shaping. It avoids embedding collection-processing logic in prompts.
Learn more: TRANSFORM.
Tool execution constructs
CALL
CALL invokes a registered tool. Keep one tool call per step when sequencing matters, and chain calls through THEN.
WITH maps tool parameters to literals, variables, dotted paths, or expressions. AS stores the result for later use.
Learn more: Tools for tool declaration and binding types.
ON_SUCCESS, ON_FAILURE, and ON_FAIL
ON_SUCCESS and ON_FAILURE handle the two basic outcomes of a tool call.
ON_SUCCESS and ON_FAILURE for structured success/failure handling around a CALL. Use ON_RESULT when the tool returns several business outcomes that require different paths. Use ON_FAIL for CHECK failure routing and other documented failure fallbacks. ON_FAILURE is also used by handoff configuration, so its meaning depends on where it appears.
Learn more: ON_SUCCESS / ON_FAIL.
ON_RESULT
ON_RESULT branches on fields in a tool result or deterministic flow context. Branches are evaluated in author order; the first matching branch wins.
CHECK
CHECK evaluates a deterministic boolean guard after state has been gathered or a tool has returned.
CHECK for local step prerequisites. If CHECK is false and no ON_FAIL target is provided, the step halts rather than automatically choosing a recovery path. Use CONSTRAINTS for reusable business rules that apply across multiple steps or boundaries.
Learn more: CHECK.
CONSTRAINTS
CONSTRAINTS declares reusable business invariants outside an individual step. Constraints are flattened and evaluated in declaration order on each turn; labels organize them but don’t control execution order. A constraint can REQUIRE, WARN, LIMIT, or RESTRICT a condition, optionally scoped with WHEN, and define ON_FAIL behavior.
CHECK when the rule is local to one flow step. LIMIT and RESTRICT remain distinct constraint kinds, but initially share the runtime handling path. If a failed constraint must clear state before retrying, route to a dedicated step that performs CLEAR — don’t assume ON_FAIL itself clears variables. See Memory and Constraints for the full constraint syntax, severity levels, and evaluation order.
Branching and navigation
ON_INPUT
ON_INPUT routes based on the current user input using deterministic boolean expressions.
ON_INPUT for explicit, reproducible choices. Don’t use it to make an LLM semantic judgment — use DIGRESSIONS or a reasoning step for that.
Learn more: ON_INPUT.
IF and ELSE
IF defines a branch condition. An omitted condition represents ELSE. Both appear in ON_INPUT and ON_RESULT branches.
GOTO
GOTO jumps directly to a named step. It’s useful for cancellation, correction, and recovery paths.
DIGRESSIONS
DIGRESSIONS handle intent-based escapes from the current step. Unlike ON_INPUT, digressions are for semantic intents such as help, cancellation, or an urgent request.
global_digressions can be declared under FLOW for behavior available in every step. A digression can RESPOND, SET, CLEAR, CALL, DELEGATE, HANDOFF, GOTO, or RESUME.
Learn more: Digressions and Global digressions.
SUB_INTENTS
SUB_INTENTS handle step-local intents without leaving the step.
COMPLETE_WHEN
COMPLETE_WHEN defines when a collection step is complete. This is especially useful when several fields may be extracted from one user message.
COMPLETE_WHEN controls collection completion. It isn’t a replacement for a final business-rule CHECK or CONSTRAINT.
Learn more: COMPLETE_WHEN.
Programming and logic patterns
Re-entry as looping
ABL doesn’t use a general-purposeWHILE or FOR statement in an authored flow. A loop is expressed by transitioning back to a named step with THEN or GOTO. State variables provide the loop condition; MAX_ATTEMPTS bounds execution of a step, but it isn’t a general-purpose loop predicate.
Guarded state transitions
UseWHEN, CHECK, ON_INPUT, and ON_RESULT as the equivalent of guarded statements. Keep predicates side-effect-free and put mutations in SET or CLEAR actions.
Counters and bounded retries
UseSET to maintain counters and MAX_ATTEMPTS to enforce a hard bound.
Terminal paths
COMPLETE ends the flow. ESCALATE ends the scripted path by routing to a human. Both should be explicit for success, cancellation, validation failure, and unrecoverable error paths.
ON_ERROR
ON_ERROR handles named runtime or tool errors at the agent level or, with a TYPE entry, at an individual flow step. Use it for centralized recovery, retry, response, or escalation policy. Use ON_FAILURE for structured call failure handling and ON_FAIL for guard/fallback failure routing.
THEN: ESCALATE with REASON: "...". Don’t use an unsupported nested escalation-priority form inside ON_ERROR.
Step-level handlers can additionally narrow an error with SUBTYPE, add retry delay/backoff, or route validation failures back to a collection step:
COMPLETE rules can also define conditional completion responses. Interactive ACTIONS and ON_ACTION can be used as a typed input alternative to free-form ON_INPUT branching when the valid choices are known.
Learn more: ON_ERROR handlers for agent-level errors, or step-level error handling for the TYPE/SUBTYPE form shown above.
Built-in expression functions
Expressions can be used inSET, CHECK, WHEN, ON_INPUT, ON_RESULT, FILTER, MAP, and templates. Boolean expressions support comparisons and AND/OR/NOT. Keep them side-effect-free.
Example normalization:
TO_NUMBER can return null, and DIV returns null on division by zero — use COALESCE, CHECK, or a result branch before continuing. See Expressions and functions for the complete function reference, operator precedence, and type coercion rules.
End-to-end example: funds transfer
The following example combines collection, normalization, tool calls, checks, result branching, correction, cancellation, and completion.Choosing the right construct
Design guidelines
- Keep deterministic work in
REASONING: falsesteps and reserve reasoning steps for interpretation or open-ended decisions. - Use one
CALLper step when tool ordering and failure routing matter. - Prefer
ON_RESULTfor business statuses such asvalid,duplicate, oraccount_closed. UseON_FAILUREfor tool execution failures andON_FAILfor guard/fallback failures where documented. - Clear dependent state whenever an earlier user choice changes.
- Use
ON_INPUTfor explicit boolean conditions andDIGRESSIONSfor semantic intent handling. - Use
CHECKfor local prerequisites andCONSTRAINTSfor reusable cross-step or boundary rules. - Shape arrays with
TRANSFORMbefore presenting them to the user. - Make every normal, failure, cancellation, retry, and escalation path explicit.
- Treat re-entry to a named step as a loop and always give it a bounded exit condition.
- Keep calculations and data shaping in expressions and
TRANSFORM. Keep user-facing wording inRESPOND. - Use
DELEGATEandHANDOFFonly when the problem genuinely crosses an agent ownership boundary.