Overview
ON_START handler
TheON_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:welcome from the agent’s TEMPLATES: block.
ON_START with tool call
Conditional greeting
Use aBRANCHES: 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
TheHOOKS: 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
TheON_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 errortype (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 formerror_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
- Step-level handlers are checked first, matching on error type and optional subtypes.
- Agent-level handlers (
ON_ERROR:block) are checked if no step-level handler matches. - If no handler matches, the runtime uses the default error message from the
MESSAGES:block (error_default).
Related pages
- Memory & Constraints — variables initialized in ON_START and hooks
- Multi-Agent & Supervisor — ESCALATE and HANDOFF used in THEN actions
- Rich Content & Expressions — voice and rich content in handler responses