Skip to content
mentoor

A support-ticket triage agent

For engineers

Build and judge a ticket-triage agent: route tickets, gate the chain, escalate risky cases, show clear errors and measure quality in production.

A support-ticket triage agent works when each stage does one small job, a line of code checks every handoff, and a person owns every case the system should not decide. The model is the smallest part. The design around it decides whether customers are helped or misled.

The situation

Brightlane sells invoicing software to small firms. It receives about 600 tickets a day by email and chat. The support team wants an agent that reads each ticket, works out what it is about, drafts a reply from the help centre and billing records, and sends only what is safe. Anything else goes to a person with the full context. The team also wants to know, a month after launch, whether the agent really helps.

This one case uses four skills: customer support with AI, workflow patterns, online evaluation, and error states.

Stage 1: route first

Do not give one prompt every ticket. Classify the ticket (billing, bug, how-to, cancellation, legal or security, other) and send it to a handler built for that category. Billing needs the invoice record. A how-to needs help articles. A legal threat needs a human. The classifier returns a category and a confidence, and anything below the threshold goes to a fallback, not to the most common handler. This is the routing pattern.

Stage 2: rules a model cannot overrule

Some tickets go to a person whatever the classifier says: a legal threat, a security report, a customer who says the billing error has put them in hardship, a third contact about the same problem, an angry tone. Write these as code rules that run before and after the model. The model can add a ticket to this list. It cannot remove one.

Stage 3: a chain with gates

Behind the router, the billing handler is a short chain. Extract the invoice number. Check in code that the invoice exists and belongs to this customer. Fetch the record. Draft the reply from the record and the refund policy. A code gate between steps stops bad output early: a made-up invoice number never reaches the drafting step. A second model call checks the draft against the policy and returns pass or fail. If it fails twice, the ticket goes to a person. Never let a generate-and-critique loop run without a cap.

Stage 4: errors that say what failed

The classifier will time out. The billing system will be down. A draft will be blocked by a filter. In each case the customer must see what happened and what comes next, plus a short reference id. "Your ticket is saved and a person will reply within four working hours. Reference BL-7F3A" is a real message. "Something went wrong" is not. The ticket text is saved before any model call, so no failure loses what the customer typed, and the fallback for every failure is the human queue.

Stage 5: measure what happens in production

Offline tests tell you the agent was good on last month's tickets. They do not tell you about next month's. Track on live traffic: the share of drafts that agents edit heavily, the wrong-answer rate found in sampled reviews, the re-contact rate within seven days, escalations, latency and cost per ticket. Deflection alone misleads, because a customer who gives up looks the same as one who got an answer. Run an LLM judge on a small random sample of traces, redact personal data first, and alert on a rolling window, not on single traces. Thumbs ratings are sparse and biased toward angry and delighted customers, so they supplement sampling and never replace it.

Stage 6: close the loop

Every flagged or sampled failure is triaged into a category. The recurring ones become test cases in the offline eval set, and each new case should fail on the current prompt before you change anything. Then fix, rerun the whole set, and release behind a flag. Tell customers and the support team what changed. A failure that never becomes a test case will come back.

What goes wrong

  • Raising the router threshold to chase accuracy sends most tickets to the fallback and floods the human queue.
  • A draft promises a refund the policy does not allow, and the company is held to it. In 2024 a Canadian tribunal ordered Air Canada to honour what its chatbot told a customer.
  • The team celebrates a rising deflection rate while re-contacts double.

Start small: route, gate, escalate, measure, and widen the agent's scope only as the numbers earn it.

Steps

  1. Route the ticket to the right handler

    Skill: agent-patterns

    Classify each ticket and dispatch it to a handler built for that category. Set one confidence threshold and send everything below it to a fallback that puts the ticket in the human queue, not to the biggest handler.

    Brightlane routing table
    CategoryHandlerRule
    BillingInvoice lookup + reply draftConfidence 0.70 or higher
    How-toHelp-article answerConfidence 0.70 or higher
    BugBug intake form + draftAttach app version
    Legal or securityHuman queueAlways, any confidence
    UnclearHuman queueConfidence below 0.70
  2. Write the rules the model cannot overrule

    Skill: ops-support

    List the cases that always go to a person: legal threats, security reports, hardship, a third contact on one problem, and angry tone. Run these as code before and after the model, so the model can add a ticket to the list but never remove one.

    Escalation rules
    1. A ticket that mentions a lawyer, a chargeback or a regulator goes to the human queue.
    2. A ticket that says a billing error has caused hardship (rent, payroll, a bounced payment) goes to the priority queue.
    3. The third ticket on the same problem within 14 days goes to a person with the earlier replies attached.
    4. The agent never offers a refund, credit or exception outside the written refund policy.
  3. Chain the billing handler with code gates

    Skill: agent-patterns

    Split the handler into steps and put a check in code between them. A made-up invoice number must die at the gate, before drafting. Add a policy check on the draft with a cap of two retries, then hand over to a person.

    Billing handler chain

    Goal: Draft a safe reply to a billing ticket

    1. 1. Extract the invoice number from the ticket.
    2. 2. Gate: the invoice exists and belongs to this customer, else escalate.
    3. 3. Fetch the invoice and payment record.
    4. 4. Draft the reply from the record and the refund policy.
    5. 5. Gate: a second call checks the draft against the policy, pass or fail.
    6. 6. On two fails, escalate with both drafts attached. On pass, queue for send.
  4. Show errors that name the failure and the next step

    Skill: aiux-errors

    Save the ticket before any model call. Then map each failure to a message with the cause, what happens next and a reference id, and make the human queue the fallback for all of them.

    Failure messages
    FailureMessage to customerFallback
    Classifier timeoutYour ticket is saved. A person will reply within 4 working hours. Reference BL-7F3A.Human queue
    Billing system downWe cannot see your invoice right now. Your ticket is saved and we will reply once it is back. Reference BL-91C2.Human queue
    Draft blocked by filterYour ticket needs a person to read it. We have passed it on. Reference BL-2D80.Human queue
  5. Pick production metrics and sample traces

    Skill: evals-online

    Track edit rate on drafts, wrong-answer rate from sampled reviews, re-contact within seven days, escalation rate, latency and cost per ticket. Judge a random 5 percent of traces with redacted text, and alert on a rolling window.

    Online judge config
    judge:  sample_rate: 0.05  model: judge-small  redact_pii: true  criteria: [policy_match, correct_invoice, tone]alert:  window: 7d  metric: policy_match_fail_rate  threshold: 0.03
  6. Turn failures into test cases

    Skill: evals-online

    Triage flagged and sampled traces weekly. Add each recurring failure to the offline eval set, confirm it fails on the current prompt, then fix, rerun the whole set and release behind a flag.

    Weekly failure review
    FailureCountHarmAction
    Refund promised outside 14 days7HighAdd 3 cases, fix prompt
    Wrong plan name in reply12LowFix help article
    Hardship ticket sent to normal queue2HighAdd rule, add cases
  7. Tell people what changed

    Skill: aiux-errors

    Close the loop with the people affected. Publish a short changelog for the support team, and where a customer reported a failure, tell them it is fixed. Capture feedback with a thumbs plus an optional reason, never a mandatory form.

Skills this scenario uses

Where to study