Concept
A supervisor with priority gates combines two routing modes in a single HANDOFF block:- Deterministic gates use structured expressions (field comparisons, IS SET checks) and are evaluated first. They enforce hard requirements such as “the user must be authenticated before any account operation.”
- Semantic routes use quoted natural-language conditions or intent-category comparisons and are evaluated after the gates pass. The reasoning model chooses the best specialist based on the user’s intent.
EXPECT_RETURN: true, the child agent runs and then returns control. The supervisor can then reprocess the original user intent (action: resume_intent) or continue where it left off (action: continue).
History default
When you omitHISTORY: on a handoff, the platform default is full — the child agent receives the entire parent conversation history. This is important to understand because:
- For temporary gate agents (authentication, compliance), you may want
HISTORY: auto(summary-first, falling back to the last 5 messages) orHISTORY: noneto avoid passing unnecessary context. - For permanent ownership transfers (billing specialist),
fullis usually appropriate so the specialist has complete conversation context.
full (default), auto, none, summary_only, and { mode: last_n, count: <n> }.
Minimal working example
How it works
- The supervisor receives the user message and keeps ownership until a route matches.
- Intent categories, runtime context, gathered values, or tool results provide the routing evidence.
- HANDOFF entries are evaluated in authored order (first = highest priority). The compiler assigns
priority: 1, 2, 3, ...based on position, and the runtime sorts by priority (lower = first). - The first matching WHEN condition wins. Deterministic gates at the top of the list are always checked before semantic or intent-based routes below them.
- When a handoff fires, the child agent receives the PASS fields, the summary, and conversation history according to the HISTORY strategy. The default strategy is
full(entire parent history). UseHISTORY: autoorHISTORY: nonewhen you want the gate agent to receive less context. - If the child is temporary (
EXPECT_RETURN: true), it returns throughON_RETURN. The supervisor then either resumes intent routing (action: resume_intent) or continues its current flow (action: continue). - If the child owns the conversation (
EXPECT_RETURN: false), it remains the active agent permanently.
Common variations
Authentication gate before account or billing specialists
UseEXPECT_RETURN: true with ON_RETURN: action: resume_intent so the supervisor reprocesses the original user intent after authentication completes. Set HISTORY: auto to give the auth agent only a summary instead of full conversation history.
VIP escalation route before ordinary queue routing
Place the VIP check after mandatory gates but before standard business routes. Use a quoted natural-language WHEN condition when the routing evidence comes from business context rather than a single ABL field.Compliance gate with explicit PRIORITY field
When you need to override the default authored-order priority, use thePRIORITY: field. Lower values are evaluated first.
CONTEXT shorthand
PASS, SUMMARY, and HISTORY can also appear as direct siblings of the handoff entry instead of nested under CONTEXT. Both forms are equivalent.Verification
- Parse the ABL and confirm there are no parser errors or warnings.
- Compile the ABL and confirm there are no compiler errors. Review any warnings about undeclared field references — these indicate variables that must be supplied at runtime from context, tool results, or project configuration.
- Test each routing path with a representative utterance:
- For the authentication gate: send any message when
is_authenticatedis not set. Expect the supervisor to route to Authentication_Agent. - For the VIP route: send “I need to speak with someone about my enterprise account” when the customer tier is platinum. Expect Priority_Care_Agent.
- For intent routes: send “I have a billing question” and confirm the Billing_Agent is selected.
- For the fallback: send a message that does not match any defined intent. Confirm Support_Agent is selected as the fallback.
- For the authentication gate: send any message when
- After the auth gate returns, send a billing-related message and confirm the supervisor re-routes to Billing_Agent (validating
resume_intentbehavior). - Inspect routing traces for: selected target, condition result, passed context fields, history strategy applied, and return behavior when
EXPECT_RETURN: trueis used.
Production readiness checklist
- Every specialist route has a clear owner and a concise context summary.
- All variables referenced in PASS fields are declared in MEMORY:SESSION or are explicitly documented as project-local assumptions that will be populated at runtime.
- Deterministic conditions use declared, gathered, tool-result, runtime, or returned fields.
- Semantic conditions are quoted as natural-language WHEN text.
- Temporary child agents produce every field mapped in ON_RETURN.
- A fallback route with
WHEN: truecatches unmatched messages explicitly. - ON_FAILURE is set on critical routes to handle dispatch failures gracefully.
- The HISTORY strategy is chosen deliberately for each handoff. Use
fullfor permanent transfers,autoornonefor temporary gates that should not receive full conversation context. - Fallback behavior is explicit and does not hide missing intent coverage.
- Routes are tested with representative utterances for each path, including the fallback and the post-gate resume path.
Common mistakes
Troubleshooting
Related articles