Skip to main content

Documentation Index

Fetch the complete documentation index at: https://koreai-v2-agent-platform-dev.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

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

HandlerWhen it fires
ON_STARTOnce per session, before any user input.
HOOKSAt defined lifecycle points (before/after agent, turn).
ON_ERRORWhen a specific error type occurs during execution.

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:
  SET:
    session_initialized = true
    transfer_status = "pending"
    retry_count = 0
  CALL: check_returning_user()
  RESPOND: |
    Welcome to Wire Transfer Services. I can help you send
    a domestic or international wire transfer.
    Which account would you like to send from?

ON_START properties

PropertyTypeRequiredDefaultDescription
SETRecord<string,string>NoVariable assignments executed at session start.
CALLstringNoTool to call during initialization.
DELEGATEstringNoAgent to delegate to during initialization.
RESPONDstringNoGreeting or welcome message sent to the user.
VOICEobjectNoVoice-specific overrides for the response. See Rich Content.
RICH_CONTENTobjectNoRich content format variants. See Rich Content.
ACTIONSobjectNoInteractive actions attached to the response.

Template references in ON_START

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

ON_START with tool call

ON_START:
  CALL: check_cut_off_times(transfer_type = "all")
  SET:
    sanctions_clear = false
    fraud_score = 0
  RESPOND: "Welcome. Let me check today's processing windows."
The tool call executes first, and its result is available in the session context when the RESPOND message is rendered.

HOOKS

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

Syntax

HOOKS:
  before_agent:
    SET:
      agent_start_time = NOW()
    CALL: load_user_preferences()

  after_agent:
    CALL: save_session_summary()

  before_turn:
    SET:
      turn_start_time = NOW()

  after_turn:
    CALL: log_audit_event()
    SET:
      turn_count = ADD(turn_count, 1)

Hook points

HookWhen it fires
before_agentOnce when the agent is first activated (before it processes its first message).
after_agentOnce when the agent completes or is deactivated.
before_turnBefore each user message is processed.
after_turnAfter each turn completes (after the agent’s response is sent).

Hook action properties

Each hook supports the same set of action properties:
PropertyTypeRequiredDefaultDescription
SETRecord<string,string>NoVariable assignments.
CALLstringNoTool to call.
RESPONDstringNoMessage to send (uncommon in hooks, but supported).
VOICEobjectNoVoice-specific overrides.
RICH_CONTENTobjectNoRich content format variants.
ACTIONSobjectNoInteractive actions.

Example: audit logging hook

HOOKS:
  after_turn:
    CALL: log_wire_audit_event()

Example: turn timing

HOOKS:
  before_turn:
    SET:
      turn_start_time = NOW()
  after_turn:
    SET:
      turn_duration_ms = SUB(NOW_MS(), turn_start_time_ms)

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

ON_ERROR:
  tool_timeout:
    RESPOND: "That system is responding slowly. Let me retry."
    RETRY: 2
    THEN: CONTINUE

  tool_error:
    RESPOND: "I hit an error accessing that service. Let me try again."
    RETRY: 1
    THEN: CONTINUE

  validation_error:
    RESPOND: "That value doesn't look right. Could you double-check?"
    THEN: CONTINUE

  llm_error:
    RESPOND: "I'm having trouble processing your request."
    RETRY: 1
    RETRY_BACKOFF: exponential
    RETRY_MAX_DELAY: 10000
    THEN: ESCALATE

Error types

Error typeWhen it occurs
tool_timeoutA tool call exceeds its timeout.
tool_errorA tool call returns an error.
validation_errorUser input fails validation.
llm_errorThe LLM call fails (rate limit, model error, etc.).
routing_failureThe Supervisor cannot route a message.
agent_unavailableA target agent for handoff or delegate is unavailable.
timeoutA general timeout (session idle, async operation).

Error handler properties

PropertyTypeRequiredDefaultDescription
RESPONDstringNoMessage sent to the user when this error occurs.
VOICEobjectNoVoice-specific overrides for the response.
RICH_CONTENTobjectNoRich content format variants.
ACTIONSobjectNoInteractive actions.
RETRYnumberNoNumber of retry attempts before executing THEN.
RETRY_DELAYnumberNoDelay in milliseconds between retries.
RETRY_BACKOFFstringNoBackoff strategy for retries. See Retry strategies.
RETRY_MAX_DELAYnumberNoMaximum delay between retries in milliseconds.
THENstringNoAction after retries are exhausted. See Then actions.
BACKTRACK_TOstringNoTarget step for backtrack action.
subtypesstring[]NoError subtypes for fine-grained matching (e.g., [rate_limit, model_error]).

Retry strategies

StrategyBehavior
fixedWait the same RETRY_DELAY between each attempt.
exponentialDouble the delay after each attempt, up to RETRY_MAX_DELAY.
linearIncrease the delay by RETRY_DELAY after each attempt, up to RETRY_MAX_DELAY.

Then actions

ActionBehavior
CONTINUEContinue the conversation, skipping the failed operation.
ESCALATETrigger human escalation.
HANDOFFTransfer to a specified agent (e.g., HANDOFF Live_Agent).
COMPLETEEnd the conversation.
backtrackReturn to a previous step specified by BACKTRACK_TO.

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.
FLOW:
  steps:
    execute_payment:
      CALL: process_payment
      ON_ERROR:
        - TYPE: tool_error
          RESPOND: "Payment processing failed. Retrying..."
          RETRY: 3
          RETRY_BACKOFF: exponential
          THEN: HANDOFF Payment_Support

Step-level error handler properties

PropertyTypeRequiredDefaultDescription
TYPEstringYesError type to match.
subtypesstring[]NoError subtypes for fine-grained matching.
RESPONDstringNoMessage to the user.
RETRYnumberNoRetry count.
RETRY_DELAYnumberNoDelay between retries (ms).
RETRY_BACKOFFstringNoBackoff strategy.
RETRY_MAX_DELAYnumberNoMaximum retry delay (ms).
THENstringNoAction after retries are exhausted.
BACKTRACK_TOstringNoTarget step for backtrack.

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).