Skip to main content
ABL provides lifecycle handlers and hooks that execute at specific points in an agent’s execution cycle. These allow you to initialize state, run side effects, and handle errors without embedding that logic in the main conversation flow.

Overview

ON_START handler

The ON_START handler executes once when a new session initializes, before the agent processes any user input. Use it for greeting messages, initial tool calls, and variable initialization.

Syntax

ON_START properties

Template references in ON_START

You can reference named templates in the RESPOND value:
This renders the template named welcome from the agent’s TEMPLATES: block.

ON_START with tool call

The tool call executes first, and its result is available in the session context when the RESPOND message is rendered.

Conditional greeting

Use a BRANCHES: block to vary the greeting based on session context. Each branch is an IF (or CONDITION) with a fallback ELSE, and can carry RESPOND, MESSAGE_KEY, VOICE, rich content, and ACTIONS.

HOOKS

The HOOKS: block defines actions that run at four lifecycle points. Unlike ON_START, hooks fire repeatedly throughout the session.

Syntax

Hook points

Hook action properties

Each hook supports the same set of action properties:

Example: audit logging hook

Example: turn timing

ON_ERROR handlers

The ON_ERROR: block defines how the agent responds to specific error types. Each handler matches an error type and specifies a response, optional retry logic, and a follow-up action.

Syntax

Error types

The error type (the handler’s key) is a free-form label matched by name — it is not validated against a fixed enum. A handler fires only when the runtime raises an error of that exact type. Commonly used types include: Use subtypes (or the SUBTYPE: singular alias) to match more finely within a type.

Inline shorthand

For a handler that only takes a terminal action, use the single-line form error_name: ACTION:

Error handler properties

Retry strategies

Then actions

Step-level error handlers

Error handlers can be overridden at the step level within a flow. Step-level handlers take precedence over agent-level handlers for the same error type.

Step-level error handler properties

Error handler resolution order

  1. Step-level handlers are checked first, matching on error type and optional subtypes.
  2. Agent-level handlers (ON_ERROR: block) are checked if no step-level handler matches.
  3. If no handler matches, the runtime uses the default error message from the MESSAGES: block (error_default).