Skip to main content
Enterprise routing often depends on more than intent. A voice caller may need a different path than a web user, a Spanish-speaking user may need a language-specific specialist, and an administrator may need a privileged-support queue. ABL lets a supervisor combine deterministic context paths and semantic conditions in the same HANDOFF list to route on channel, locale, role, entitlement, failure count, or session state. Use this when the same user intent must branch by channel, language, role, or current session state.

Concept

A supervisor evaluates HANDOFF entries in authored order. Each entry has a WHEN condition that can be either:
  • Deterministic: a structured expression referencing session data values, such as session.channel == "voice" or session.interaction.current.language == "es". The runtime evaluates these against session state and produces a boolean result without involving the model.
  • Semantic: a natural-language description of when the route should activate, such as "the user is an administrator and the account is locked". The runtime defers these to the model, which decides based on conversation context.
You can mix both in the same HANDOFF list. Deterministic conditions are reliable for known, platform-provided values. Semantic conditions are flexible for signals that come from conversation context, identity systems, or policy rules that are not yet in structured session data. When no HANDOFF condition matches, the supervisor retains ownership and may respond directly or re-prompt the user. Always include a catch-all route or ensure the supervisor has a meaningful direct-response capability.

Key context paths

History default

When a HANDOFF entry omits the history property, the child agent receives the full parent conversation history. This is the platform default. To limit what the child sees, set history explicitly:
  • full (default when omitted): complete parent conversation history
  • auto: uses the handoff summary when available, otherwise the last 5 messages
  • summary_only: only the summary text, no raw messages
  • none: no history
  • { mode: last_n, count: <n> }: the last N messages

Minimal working example

This supervisor routes by channel, language, role, and a general fallback. Each variable in pass must be populated before routing — typically via ON_START SET, GATHER, a tool call, or caller context from the SDK/channel.
Variable sourcing assumptions: customer_id and account_id are populated from caller context or an ON_START lookup. conversation_summary is a platform-provided session variable. These must exist in session data before the HANDOFF evaluates. This example uses the flat CONTEXT shorthand (PASS:, SUMMARY:, HISTORY: as direct siblings of the HANDOFF entry). The nested CONTEXT: wrapper form is also supported:
Both forms produce identical results.

How it works

  1. The supervisor receives the user message and evaluates HANDOFF entries in authored order.
  2. For each entry, the runtime classifies the WHEN condition:
    • Structured conditions (containing operators like ==, !=, AND, OR, IS SET, comparisons) are evaluated deterministically against session data values.
    • Natural-language conditions (free-form text without operators) are deferred to the model, which decides based on conversation context and the condition text.
  3. The first matching handoff transfers control to the target agent. The target receives the declared pass variables, the summary, and conversation history according to the history strategy (default: full).
  4. When EXPECT_RETURN: false, the child becomes the new active agent permanently. When EXPECT_RETURN: true, the child returns control to the supervisor via ON_RETURN.

Common variations

Combining deterministic and semantic conditions

You can combine a deterministic check with a semantic qualifier in a single WHEN using AND:
The runtime evaluates the deterministic part first. If it passes, the semantic part is deferred to the model. Both must be true for the route to match.

Routing on locale instead of language

Routing with explicit priority

Use PRIORITY to override authored-order evaluation. Lower values are evaluated first:

Return-expected handoff with ON_RETURN

When a specialist should return control after completing its task:

Adding ON_FAILURE for robustness

ON_FAILURE fires when the target agent cannot be found or the dispatch fails before the target accepts the handoff.

Verification

  • Validate the ABL document parses and compiles without errors or warnings.
  • Send a test message from a voice channel and confirm the Voice_Escalation_Agent is selected. Inspect the trace for a routing_primitive_when event showing kind: deterministic_pass for the session.channel == "voice" condition.
  • Send a test message with the interaction context language set to es and confirm the Spanish_Service_Agent is selected.
  • Send a test message as an administrator (with role context populated) and confirm the Admin_Support_Agent is selected via model-deferred semantic evaluation.
  • Send a test message that matches no specific override and confirm the Standard_Service_Agent is selected.
  • Confirm that each target agent receives the expected pass variables and conversation history.

Production readiness checklist

  • Every variable in pass lists has a verified source: gathered field, ON_START SET, caller context, tool output, or memory. Variables that are not populated before routing will be passed as empty/null.
  • Deterministic conditions use platform-provided paths (session.channel, session.interaction.current.language) or variables with known, reliable sources.
  • Semantic conditions describe clear, unambiguous selection criteria. Vague conditions may cause inconsistent routing.
  • The history default is full when omitted. If children should not see full history, set history explicitly on each handoff.
  • A catch-all route or direct-response capability exists for messages that match no specific route.
  • Each specialist agent is defined and reachable (either inline or as an imported agent reference).
  • ON_FAILURE is set on critical routes where target unavailability must produce a user-facing message rather than silence.
  • Route distinctness: each deterministic WHEN condition is mutually exclusive or ordered so the first match wins correctly. Overlapping semantic conditions may produce non-deterministic routing.

Common mistakes

Troubleshooting


Related articles