Skip to main content
ABL supports two complementary execution styles:
  • 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.
Use scripted flows when ordering, auditability, predictable cost, or strict business rules matter. Typical examples include payments, identity verification, regulated disclosures, onboarding forms, and support procedures with fixed escalation rules. This guide treats ABL as a programming and logic language: variables, expressions, validation, branching, state reset, collection processing, tool calls, retries, and terminal paths. Agent coordination is an integration boundary rather than the focus of this page — see Multi-Agent and Supervisor for 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.
The arrow notation communicates a sequence. The named step blocks contain the actual behavior. Learn more: Flow structure.

REASONING

REASONING controls whether a step is deterministic or LLM-assisted:
Use 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.
Learn more: Entry guards.

MAX_ATTEMPTS and ON_EXHAUSTED

MAX_ATTEMPTS limits retries for a step. ON_EXHAUSTED routes to a recovery step once the limit is reached.
Learn more: Attempt limiting.

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.
Use it for instructions, confirmations, validation messages, receipts, and error recovery. Learn more: SAY / RESPOND.

PRESENT

PRESENT shows context before a GATHER operation.
Learn more: PRESENT.

GATHER

GATHER collects one or more fields from the user. It can specify type, required status, prompt, defaults, validation, extraction strategy, and correction behavior.
Use field validation for intrinsic values such as date format or account-number shape. Use 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.
Inline assignment is useful inside branches:
Use 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.
Clear all dependent values, not just the field the user changed. Learn more: CLEAR.

TRANSFORM

TRANSFORM applies a declarative array pipeline. The stages are FILTER, MAP, SORT_BY, and LIMIT.
Use 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.
Use 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.
Learn more: ON_RESULT.

CHECK

CHECK evaluates a deterministic boolean guard after state has been gathered or a tool has returned.
Use 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.
Use constraints for rules that must remain true across several paths or at a tool/result boundary. Use 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.
Use 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.
Learn more: Sub-intents.

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-purpose WHILE 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

Use WHEN, 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

Use SET 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.
Learn more: COMPLETE and ESCALATE.

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.
For escalation from an error handler, use 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:
The runtime’s flow order is significant: response, gather, call, check, result/failure handling, input handling, then the default transition. Don’t assume a later action runs after a branch has already transitioned. Top-level 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 in SET, 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:
Guard nullable results before arithmetic or field access. 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

  1. Keep deterministic work in REASONING: false steps and reserve reasoning steps for interpretation or open-ended decisions.
  2. Use one CALL per step when tool ordering and failure routing matter.
  3. Prefer ON_RESULT for business statuses such as valid, duplicate, or account_closed. Use ON_FAILURE for tool execution failures and ON_FAIL for guard/fallback failures where documented.
  4. Clear dependent state whenever an earlier user choice changes.
  5. Use ON_INPUT for explicit boolean conditions and DIGRESSIONS for semantic intent handling.
  6. Use CHECK for local prerequisites and CONSTRAINTS for reusable cross-step or boundary rules.
  7. Shape arrays with TRANSFORM before presenting them to the user.
  8. Make every normal, failure, cancellation, retry, and escalation path explicit.
  9. Treat re-entry to a named step as a loop and always give it a bounded exit condition.
  10. Keep calculations and data shaping in expressions and TRANSFORM. Keep user-facing wording in RESPOND.
  11. Use DELEGATE and HANDOFF only when the problem genuinely crosses an agent ownership boundary.