Skip to main content
Back to how-to guides Use this pattern when a supervisor must enforce a mandatory check, such as consent, identity, or VIP handling, before it routes to a business specialist.

Concept

A gate is a HANDOFF route that must win before any business route. ABL has no separate gate construct. You build a gate from route order and from guard conditions. Three rules shape every gate.
  1. Position is priority. The first entry in HANDOFF: has the highest priority. The PRIORITY: field is read and then ignored. Reorder the entries instead.
  2. An expression is a guard. When the model calls a route, the platform tests that route’s WHEN. A false expression refuses the route. When exactly one other route has a true expression, the refusal message names it to the model.
  3. The model path does not force the gate first. The model can call a business route directly. Only that route’s own WHEN can stop it. Repeat the gate fact in the WHEN of every protected route.

Where the order applies

The pipeline runs only when the project enables it. See How to use EXECUTION.pipeline for agent routing, classification, and short-circuiting.

Gate facts

A gate is only as strong as its fact. Use a fact that the platform sets, such as session.identityTier. Or use a fact that a child agent collects, such as consent. Do not use a value that the customer or the model can state without a check. A missing value behaves differently by operator. Write gates with != true and protected routes with == true. A missing value then closes the protected routes and opens the gate.

Plain-language gates

Do not write a gate as a quoted phrase. The pipeline treats a quoted phrase as always true. A quoted gate captures every message the pipeline classifies. Use an expression for the gate.

Minimal working example

This example puts a consent gate and a platinum priority route ahead of three business routes. Put the supervisor and all agents in the same project. The business agents are short stand-ins for your real agents. agents/priority-routing-supervisor.agent.abl
agents/consent-agent.agent.abl
agents/priority-care-agent.agent.abl
agents/billing-agent.agent.abl
agents/account-agent.agent.abl
agents/support-agent.agent.abl
agents/triage-agent.agent.abl
Project-local assumptions:
  • session.customer_tier comes from caller data that your channel or SDK sends. Treat caller data from a browser as unverified.
  • customer_id and account_id follow the same rules as in How to route users by detected intent. The platform passes the supervisor’s value when it has one. Otherwise the model fills the field from the conversation.
The table shows the route for each case.

How it works

  1. The supervisor keeps the conversation until a route fires.
  2. While consent_recorded has no value, consent_recorded != true is true. The gate route fires.
  3. EXPECT_RETURN: true pauses the supervisor. Consent_Agent asks the question and completes when consent_recorded is true.
  4. map copies the child’s consent_recorded into the supervisor’s consent_recorded. Write the child field first, then the parent field.
  5. action: resume_intent runs routing again against the customer’s original request, with the returned value.
  6. The gate is now false. The protected routes pass their consent_recorded == true test. The intent decides the route.
  7. A message that matches no earlier route falls to Triage_Agent.

Common variations

Gate on a platform identity value

Use session.identityTier when the channel verifies identity. The value is 2 after HMAC, OAuth, email link, or OTP verification. The sign-in agent in this example keeps the conversation and explains how to verify.

Hide a route with ENABLED_WHEN

WHEN refuses a route after the model calls it. ENABLED_WHEN removes the route from the model’s choices while the condition is false. Use it for routes that only some customers may see.
Write ENABLED_WHEN as an expression over data that exists before the turn. A condition that reads intent or plain language fails to compile with ENABLED_WHEN_SEMANTIC_REFERENCE. A condition that reads a missing value counts as false. ENABLED_WHEN shapes the experience. It does not replace the WHEN guard on a protected route.

Choose how the supervisor resumes

action: resume_intent replays the customer’s original request through routing. Use it when the customer asked for something before the gate ran. action: continue resumes the supervisor’s current flow. Use it when the gate is a step in a flow. Set history: none or history: summary_only on a gate agent that does not need the transcript. The default full passes the whole conversation.

Verification

  1. Start a session with no consent. Send “I need help with my invoice.” Confirm the trace shows Consent_Agent as the target.
  2. Answer yes. Confirm the trace shows the original billing request routed to Billing_Agent.
  3. Inspect the handoff_condition_check events. For each route, confirm result, whenOutcome, and the condition. A refused route shows reasonCode: handoff_condition_blocked.
  4. When the pipeline is on, inspect pipeline_routing_resolve. Confirm the matched route and its priority number.
  5. Send a message with caller data customer_tier set to platinum. Ask for a manager. Confirm Priority_Care_Agent. Repeat with another tier. Confirm Triage_Agent.
  6. Check the supervisor’s session data. Confirm consent_recorded is true after the return.
  7. Answer no to the consent question. Confirm that your policy for a decline applies.

Production readiness checklist

  • The gate fact has a source that the customer cannot set by statement.
  • The gate is the first entry.
  • Every protected route repeats the gate fact in its WHEN.
  • Every field in an ON_RETURN map exists in the child, and the child sets it before it completes.
  • The gate agent has a decline path. The example agent keeps asking until the customer agrees.
  • The fallback route is safe for a customer who has not passed the gate.
  • Critical gates have an ON_FAILURE policy.
  • Tests cover consent given, consent declined, no match, and a protected route called before the gate.

Common mistakes

Troubleshooting