Concept
A supervisor can route on data it loads before the first routing decision. Two sources work.
Each
HANDOFF has a WHEN condition. The platform evaluates a WHEN written as an expression before the model reasons. It checks the routes in the order you write them. The first route that matches takes the conversation. A PRIORITY value changes the order, and the lowest number runs first.
A route with a quoted plain-language WHEN stays with the model. Use one as the last route for every customer that no expression matched.
A comparison on a missing value is false. If the lookup fails, no expression route matches and the model chooses the plain-language route.
You do not need to copy the tool result into session variables first. A route reads profile.tier directly.
Minimal working example
This example routes on a profile lookup. It sends high-risk customers to fraud review first, then customers with an open case, then premium customers. For everyone else, including customers the lookup could not find, the model chooses the standard route. The supervisor needs the specialist agents in the same project. The lookup tool needs an execution binding in your project, such as an HTTP endpoint.session.customerId is the customer identifier that the channel resolved when it authenticated the user.
How it works
ON_STARTruns theCALLbefore the first routing check. IndentWHENunderCALL.WHEN: session.customerId IS SETskips the lookup for anonymous sessions.AS: profilestores the tool result. If the call fails or does not run,profilestays unset and all three expression routes are false.- On each customer message, the platform checks the expression routes in order before the model reasons. The fraud route comes first, so risk wins over tier.
profile.has_open_case == truematches only a booleantrue. A tool that returns the string"true"does not match.- The last route has a quoted plain-language
WHEN. The model chooses it when no expression route matched. - Write quoted text in plain lowercase words. The platform evaluates quoted text as an expression, not as guidance, when it contains uppercase
AND,OR, orNOT. It does the same for a symbol such as==or>, and for the wordscontains,matches,startsWith, orendsWith. - The specialists use
RETURN: false, so each one keeps the conversation after the transfer. - A
HANDOFFentry withoutHISTORYgives the specialist the full conversation history. A project-level coordination default can change this value. - The tool is read-only.
side_effects: falseandconfirm: nevermark it as a lookup that never asks the customer for confirmation.hints.timeoutis a number of milliseconds. The welcome and the first routing check wait for the tool, so keep it fast.
Common variations
Pass the lookup result to the specialist
AddPASS to a route when the specialist needs the profile. The specialist receives the profile object.
profile.tier compiles to its root field profile. List the root field.
Route on remembered state
Use this variation when an earlier session or an integration stored the value. This example assumes that aREMEMBER rule or the memory API saved user.loyalty_tier for the customer.
user.loyalty_tier empty. The gold route is then false and the model chooses the standard route. Declare the path with ACCESS: read and a RECALL entry. Without the RECALL, the compiler warns with INERT_PERSISTENT_MEMORY_DECLARATION.
Verification
Run one session for each outcome and inspect the trace.- Start as a customer with a high fraud risk. Expect
Fraud_Review_Agent. - Start as a customer with an open case and a low fraud risk. Expect
Existing_Case_Agent. - Start as a premium customer with no open case. Expect
Premium_Service_Agent. - Start as any other customer. Expect
Standard_Service_Agent. - Start anonymously, with no
session.customerId. ExpectStandard_Service_Agentand no lookup call. - Make the tool fail. Expect
Standard_Service_Agent.
dsl_lifecycle_call_conditionshows whether the lookup ran.tool_resultshows what the tool returned.deterministic_routingshows the matched expression route, with itscondition,target, andpriority.handoff_condition_checkshows a route the model chose. Readresult,whenOutcome, andevaluatedContextto see why the platform allowed or refused it.- For the memory variation,
memory_initshows that the session loaded the persistent value.
Production readiness checklist
- The lookup tool is read-only, has a typed return that lists every field a route reads, and has a numeric
hints.timeout. - Each field type matches its comparison. Booleans are booleans, not strings.
session.customerIdcomes from an authenticated channel. Usesession.identityTierwhen a route must depend on a verified identity.- Every specialist route has an owner and a short
SUMMARY. - A plain-language route handles every customer that no expression matched, including a failed or skipped lookup.
- If every customer must reach a specialist, set
BEHAVIORwithROLE: router. Without aBEHAVIORblock, the supervisor can answer directly instead of choosing a route. - The highest-risk route is first.
- Tests cover each route, an anonymous session, and a tool failure.
- Stored memory values have a producer, such as a
REMEMBERrule, that you can name.