EXAMPLE · Example 7.8

Customer support routing (AGENTIC)

An LLM-routed space that interprets free-form requests and dispatches to deterministic tasks.

@supportDesk:AGENTIC
>>> Routes incoming customer queries to the right task by semantic interpretation.
>
$agentic_main
>>> Interpret the request using the customer's message and metadata.
>>> If the query is about order status, call $lookupOrder.
>>> If it is a complaint, call $logComplaint.
>>> If it is a refund request, call $processRefund.
>>> Otherwise, call $fallback.
>
$lookupOrder(in=%orderID, out=%status)
>>> Fetches order status from the order database.
>
$logComplaint(in=%complaintText)
>>> Creates a complaint record in the CRM system.
>
$processRefund(in=%orderID, out=%refundReceipt)
>>> Processes a refund through the payment gateway and returns a receipt.
>
$fallback
>>> Apologises to the customer and logs the unclassified request for review.

What this shows

Semantic routing on free-form input. The :AGENTIC selector uses an LLM to interpret natural-language customer queries and pick the appropriate downstream task. The routing logic itself is written in plain English and travels with the contract.

Domain-specific tasks remain deterministic. $lookupOrder, $logComplaint, and $processRefund are normal tasks that perform precise actions. The AI’s only job is to choose between them.

Graceful unclassified handling. $fallback ensures every unrecognised request is acknowledged and logged for human review. Nothing is silently dropped.

A clean place for the AI to live. The contract names exactly where AI judgment is allowed — at the routing surface — and what it must do (call one of these specific tasks). Boundaries are auditable; the AI cannot quietly invent a new branch.

Well-suited to high input variability. This pattern is best where intent must be inferred from natural language. For input shapes that are predictable, prefer a :FUNC space.