Skip to main content
Use this pattern when your supervisor must enforce mandatory checks — authentication, fraud screening, regulatory consent, or VIP escalation — before the reasoning model selects a business route.

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.
The compiler assigns each HANDOFF entry an evaluation priority from its position in the authored list (first entry = highest priority). The runtime sorts entries by priority and evaluates them top to bottom, selecting the first match. Placing mandatory gates at the top of the HANDOFF block guarantees they are checked before any semantic route. When a gate hands off with 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 omit HISTORY: 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) or HISTORY: none to avoid passing unnecessary context.
  • For permanent ownership transfers (billing specialist), full is usually appropriate so the specialist has complete conversation context.
The supported history strategies are: full (default), auto, none, summary_only, and { mode: last_n, count: <n> }.

Minimal working example

How it works

  1. The supervisor receives the user message and keeps ownership until a route matches.
  2. Intent categories, runtime context, gathered values, or tool results provide the routing evidence.
  3. 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).
  4. 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.
  5. 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). Use HISTORY: auto or HISTORY: none when you want the gate agent to receive less context.
  6. If the child is temporary (EXPECT_RETURN: true), it returns through ON_RETURN. The supervisor then either resumes intent routing (action: resume_intent) or continues its current flow (action: continue).
  7. If the child owns the conversation (EXPECT_RETURN: false), it remains the active agent permanently.

Common variations

Authentication gate before account or billing specialists

Use EXPECT_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 the PRIORITY: 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_authenticated is 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.
  • After the auth gate returns, send a billing-related message and confirm the supervisor re-routes to Billing_Agent (validating resume_intent behavior).
  • Inspect routing traces for: selected target, condition result, passed context fields, history strategy applied, and return behavior when EXPECT_RETURN: true is 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: true catches 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 full for permanent transfers, auto or none for 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