Concept
A gate is aHANDOFF 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.
- Position is priority. The first entry in
HANDOFF:has the highest priority. ThePRIORITY:field is read and then ignored. Reorder the entries instead. - 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. - The model path does not force the gate first. The model can call a business route directly. Only that route’s own
WHENcan stop it. Repeat the gate fact in theWHENof 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 assession.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
session.customer_tiercomes from caller data that your channel or SDK sends. Treat caller data from a browser as unverified.customer_idandaccount_idfollow 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.
How it works
- The supervisor keeps the conversation until a route fires.
- While
consent_recordedhas no value,consent_recorded != trueis true. The gate route fires. EXPECT_RETURN: truepauses the supervisor.Consent_Agentasks the question and completes whenconsent_recordedis true.mapcopies the child’sconsent_recordedinto the supervisor’sconsent_recorded. Write the child field first, then the parent field.action: resume_intentruns routing again against the customer’s original request, with the returned value.- The gate is now false. The protected routes pass their
consent_recorded == truetest. The intent decides the route. - A message that matches no earlier route falls to
Triage_Agent.
Common variations
Gate on a platform identity value
Usesession.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.
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
- Start a session with no consent. Send “I need help with my invoice.” Confirm the trace shows
Consent_Agentas the target. - Answer yes. Confirm the trace shows the original billing request routed to
Billing_Agent. - Inspect the
handoff_condition_checkevents. For each route, confirmresult,whenOutcome, and thecondition. A refused route showsreasonCode: handoff_condition_blocked. - When the pipeline is on, inspect
pipeline_routing_resolve. Confirm the matched route and its priority number. - Send a message with caller data
customer_tierset toplatinum. Ask for a manager. ConfirmPriority_Care_Agent. Repeat with another tier. ConfirmTriage_Agent. - Check the supervisor’s session data. Confirm
consent_recordedis true after the return. - 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_RETURNmapexists 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_FAILUREpolicy. - Tests cover consent given, consent declined, no match, and a protected route called before the gate.