Concept
ON_START is the session-start handler. The runtime runs it once per session, before the agent processes user input. It does not run again on later messages.
Use ON_START for work that belongs to session startup: greeting the user, reading context, loading a profile, setting values, or choosing the first-turn experience. Do not use it for per-turn routing.
ON_START can hold these parts. The runtime runs them in this order.
The welcome reaches the user only on channels that allow it, and only when the session starts before the first message. The other parts run in every case. The welcome HowTo lists the channels.
Minimal working example
This agent copies the channel into a session value, then uses the value in the welcome.How it works
SET runs before RESPOND. The welcome can read the values that SET assigns. The runtime emits a dsl_set event for each assignment and a dsl_respond event for the welcome.
session.channel holds the channel type, for example web_chat. It holds digital when the session has no channel type. Behavior profiles use a different value, channel.name.
session.interaction.current.language holds the resolved language. The runtime resolves it before ON_START runs.
This agent has no FLOW, so it answers each user message with reasoning after the welcome.
Common variations
Choose a welcome with branches
Branches run in order. The first matching branch wins. AnELSE branch is the default.
IF as an expression. Plain English text does not match. A condition that cannot evaluate is skipped, and the trace shows dsl_on_start_branch_error.
If no branch matches, the runtime uses the top-level RESPOND when the agent has one. With no top-level RESPOND, the agent sends no welcome.
A branch welcome owns the startup turn. When the agent has a FLOW, the entry step does not run during startup.
Run actions at startup with a DO list
A branch cannot holdSET or CALL directly. The compiler reports error E380. Put those actions in the branch DO list. The list runs after the welcome.
A DO list accepts SET, CALL, HANDOFF, SET_INTERACTION_LANGUAGE, and CLEAR_INTERACTION_LANGUAGE. The parser drops RESPOND, DELEGATE, and other actions with warning W381. Put the welcome text in the branch RESPOND.
ON_START_BRANCH_DO_ACTIVATED. They confirm that each DO list runs at session start. Later turns and tools can read entry_source.
Hand off or delegate at startup
A top-levelHANDOFF: <Agent>, or a HANDOFF entry in a branch DO list, starts a declared local agent at session start. A top-level DELEGATE: <Agent> delegates at startup. The agent must declare each handoff target in its own HANDOFF section. Otherwise the compiler warns ON_START_HANDOFF_TARGET_INVALID, and the runtime refuses the handoff. See the welcome routing HowTo for a complete example.
Verification
- Create sessions with different language values. Confirm the selected welcome changes.
- Open the trace. Confirm
dsl_on_start, thendsl_setwithsource: on_start. - Check
dsl_on_start_branch. It shows the matched branch index and condition. It showsmatched: falsewhen no branch matches. - Confirm
dsl_respondshowssource: on_start. A branch welcome addsresponseSource: on_start_branch. - Send a second message in the same session. Confirm the trace shows no second
dsl_on_start. - Start a session over HTTP chat. Confirm
SETruns and the welcome text does not appear.
Production readiness checklist
- Put
SETandCALLat the top level ofON_START, or in a branchDOlist. - Add an
ELSEbranch or a top-levelRESPONDso every session gets a welcome. - Branch only on values that exist before the first user turn.
- Keep startup setup separate from visible text. Some channels and lazy starts drop the text.
- Check the compiler output for
ON_START_BRANCH_DO_ACTIVATEDand make sure eachDOlist is intended. - Test one session for each branch.