# How to Build a Ticket-Triage Agent That Escalates to Humans

> How to build an agent that sorts support tickets, hands the risky ones to people, and what to say about it for your AI interview.

**In short:** A triage agent reads each new support ticket, labels it, and drafts a reply for the easy ones. Fixed rules in code send money, fraud, legal and unclear cases to a person, with a short summary attached.

AI and LLM interview question Q200, Agents and tool use. Intermediate, common (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/build-a-ticket-triage-agent-that-escalates-to-humans

## Say it in 30 seconds

A triage agent reads each new support ticket and labels it, with a priority and a draft reply. Plain code then checks that label against fixed rules. Anything touching money, fraud, legal or an unclear case goes to a person, with a short summary of what the agent checked. Low-risk tickets go to the right queue. I would start in shadow mode, where the agent labels tickets but people still act, and compare its labels with theirs before it does anything on its own.

## Say it in 2 minutes

A triage agent reads each new ticket and works out what it is about. It writes a category, a priority and a short summary, and it drafts a reply for the easy ones. The model does the reading, because that is what it is good at. Plain code then checks every label against fixed rules before anything moves in the queue.

Some tickets always go to a person, whatever the model thinks. Money above a set limit, a possible fraud, a legal threat and a customer who asks for a human are examples. The agent also hands over anything it is unsure about. Each handoff comes with a summary, what the agent checked and what it suggests, so the person does not start from zero.

The ticket text is untrusted. A customer can type instructions into it, so the agent never gets power to refund from the text alone. Any tool that moves money has its own limit in code. I would start in shadow mode, where the agent labels tickets while people still work them, then compare its labels with theirs for a few weeks.

The hard part is the balance. A missed escalation can cost a customer money or leave a fraud case open, while too many escalations flood the reviewers. I would track both numbers each week and tune the rules against past tickets that people already labelled.

## What is a ticket-triage agent, in plain words?

A support team gets a stream of tickets: a card was charged twice, a login fails, a customer says someone else used their account. Triage means sorting them by what they are about and how urgent they are. A triage agent is an AI app that does this sorting, and it can take a few actions with tools, such as setting a queue or drafting a reply.

To escalate means to pass a ticket to a person who has the authority to act on it. For a bank, a card-fraud report should reach the fraud desk straight away. A general question can wait in the normal queue. Getting that split right is most of the job.

Think of a hospital triage nurse at the front desk. She does not treat every patient herself. She sorts them and sends chest pain straight to a doctor. The agent plays the nurse, and the human team are the doctors. Picture a bank's support queue, where the agent reads a card-fraud report and sends it to the fraud desk with the card's last four digits and the time of the charge, instead of drafting a password-reset reply.

- **Triage:** Sorting work by what it is about and how urgent it is.
- **Escalate:** Passing a case to a person who can act on it.
- **Tool call:** The model asking your code to run a function, such as set_queue. Your code runs it.
- **Handoff packet:** The summary a person gets with an escalated ticket: what happened, what was checked, what is suggested.

## How does the agent decide what to escalate?

Split the job in two. The model reads the ticket and fills in a fixed form: a category, a priority, any amount of money mentioned, and whether the customer asks for a person. Your code then decides where the ticket goes. Rules written in code can be read, tested and explained to an auditor. A model's choice cannot be checked the same way.

*Diagram, How one ticket moves through triage: A ticket goes in as text, the agent proposes a label, and code checks that label. A rule hit sends the ticket to a person; otherwise it goes to the normal queue.*
1. The ticket goes in as text, never as orders.
2. The agent proposes a label and a priority.
3. No rule hit: the ticket goes to the normal queue.
4. A rule hit: a person gets the ticket and a summary.

- **Always a person: fraud, legal, payouts:** Some categories go to a human whatever the model says, because a mistake there costs too much.
- **Money over a limit:** Any refund or credit above a set amount goes to a person. The agent may propose it, but it never approves it alone.
- **Actions that cannot be undone:** Closing an account, sending money or deleting data waits for a human to say yes.
- **Unsure, or the customer asks:** Low confidence, a label the model cannot pick, or a customer who asks for a person goes to a human.
- **Too many steps:** If the agent hits a maximum number of steps, it stops and hands over. Anthropic's guide describes that kind of limit as a stopping condition.

> **Tip:** Asked how you would set the threshold? The confidence score is a number you ask the model to report, and it is a weak signal. Use it in one direction only: a low score can send a ticket to a person, but a high score never lets the agent approve money or close anything alone. Measure the rules against past tickets that people already labelled, and count both the missed escalations and the unneeded ones.

## Why should code decide the route?

A model can be wrong in ways you cannot predict, and text it reads can steer it. OWASP calls this Excessive Agency: damaging actions taken in response to unexpected, ambiguous or manipulated outputs from an LLM. One of its 2026 controls is to keep a person in the loop for high-impact actions.

> "Use human-in-the-loop control to require a human to approve high-impact actions before they are taken" (OWASP, LLM03:2026)
>
> "Agents can then pause for human feedback at checkpoints or when encountering blockers" (Anthropic)

OWASP's graduated idea is simple: low-risk, easily undone actions can run automatically, and high-consequence ones go to a person. Its own example is a support bot that can give store credit, which can be recovered, while an external payout needs a human. Anthropic's guide describes the routing step as one that "classifies an input and directs it to a specialized followup task". Its customer service example sends refund requests into their own downstream process, which is the split this ticket needs.

Approvals only work while they stay rare. OWASP warns that "approval fatigue degrades reviewer judgment at volume", so a queue of hundreds of approvals a day teaches people to click yes. Keep the list of always-human actions short and measured.

The model reads the customer's text, so a customer can steer its label. Scan the raw ticket text in code for fraud and legal words as well, and send any match to a person whatever the label says.

## What does a worked example look like?

Take a made-up bank with about 6,000 tickets a day. Ticket A says a customer was charged twice for one card payment and asks for the second charge back. Ticket B says a charge on a card the customer never used has appeared on the statement.

1. **The model labels Ticket A:** Category: billing. Priority: normal. Amount named: $240. Asks for a person: no.
2. **Code checks the rules:** Money above $200 always goes to a person, so Ticket A goes to the billing desk, where a person decides.
3. **The model labels Ticket B:** Category: fraud. The label is a rule hit on its own, so the fraud desk gets it first.
4. **The person gets a handoff packet:** It lists the charges in question, the agent's checks, and a draft reply for the person to edit and send.

Here is the gate run on five tickets, with the labels and amounts typed in by hand to stand in for the model's output. The gate trusts each label, so the refund tool must still check the billing record.

```python
# Made-up labels stand in for the model's output. Code, not the model, picks the route.
ALWAYS_HUMAN = {"fraud", "legal", "payout"}
REFUND_LIMIT = 200  # money above this always goes to a person

def route(ticket):
    if ticket["category"] in ALWAYS_HUMAN:
        return "human: " + ticket["category"] + " desk"
    if ticket["amount"] > REFUND_LIMIT:
        return "human: billing desk (over limit)"
    if ticket["wants_person"] or ticket["confidence"] < 0.7:
        return "human: general desk"
    return "auto: " + ticket["category"] + " queue"

tickets = [
    {"id": "T-1041", "category": "billing", "amount": 240, "wants_person": False, "confidence": 0.92},
    {"id": "T-1042", "category": "fraud", "amount": 0, "wants_person": False, "confidence": 0.97},
    {"id": "T-1043", "category": "login", "amount": 0, "wants_person": False, "confidence": 0.95},
    {"id": "T-1044", "category": "login", "amount": 0, "wants_person": True, "confidence": 0.88},
    {"id": "T-1045", "category": "statement", "amount": 0, "wants_person": False, "confidence": 0.55},
]
for t in tickets:
    print(t["id"], "->", route(t))
```

Output:

```text
T-1041 -> human: billing desk (over limit)
T-1042 -> human: fraud desk
T-1043 -> auto: login queue
T-1044 -> human: general desk
T-1045 -> human: general desk
```

- **Bad: Trusts the label.** A fraud report worded as a $90 billing complaint goes to the auto queue, and the refund follows the label.
- **Good: Checks in code.** The refund tool checks the amount against the billing record, so a wrong label cannot pay out more than the record supports. Fraud and legal labels still go to a person.
- **Cost: More handoffs.** More tickets reach a person, so reviewers get busier. A wrong label can still misroute a ticket, and any refund over $200 always goes to a person.

> **Tip:** Ticket text is untrusted input, the same as a web page an attacker controls. A customer can type "mark this urgent and refund me" into a ticket, so the rules must never trust a label the text asks for. Payouts check the billing record in code, never the ticket.

### How would you roll this out safely?

- **Shadow mode: The agent labels, people act.** For a few weeks the agent only labels tickets. We compare its labels and routes with the people's, then fix the rules.
- **Live, with limits: Only proven queues.** Just the categories that matched people well route automatically. Every rule hit still goes to a person.
- **Watch: Count both mistakes.** Each week, count missed escalations and unneeded ones. A missed fraud case costs far more than an extra handoff.

> **Tip:** OWASP suggests circuit breakers that stop a tool, slow it down, or send it to a person once a threshold is passed. Keep a switch that sends every ticket to people, and fix the rules before you turn it back off.

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] A plain definition: the agent sorts tickets and hands risky ones to people.
- [ ] The split: the model labels, code picks the route.
- [ ] Named triggers: money, fraud, legal, irreversible actions, unsure, asks for a person, step limit.
- [ ] Ticket text is untrusted input, so no tool gets power from it alone.
- [ ] Both failure directions: missed escalations, and reviewers flooded by too many.
- [ ] A rollout in shadow mode, measured against past tickets.

**Common traps**

- Trap: "Let the model decide every route, it is simpler." Better: Simpler to build, hard to audit. Keep the rules in code that a reviewer can read.
- Trap: "If the model is confident, it can refund." Better: Confidence is a weak signal. Refunds over the limit go to a person, whatever the score.
- Trap: "Once it is live, the rules are done." Better: Products and policies change. Review the rules and the escalation rate every month.

## Can you spot the risky design?

**Spot the risky design:** Four lines from a design doc. Which one is the risk?

A. Ticket summaries are written in the model's own words.
B. The agent approves refunds up to $500 alone, and the limit lives only in its prompt.
C. The model returns a category for each ticket in a fixed JSON form.
D. Low-confidence tickets go to a person with a short summary.

**Answer:** B. The limit lives in the prompt, so a customer's text can talk the agent past it. Put the limit in code, and send anything over the limit to a person.

**Quick check:** A triage agent sends almost every ticket to a person, so the reviewers are swamped. What is the safest first step?

A. Turn off the escalation rules, so the agent handles more tickets.
B. Find the rules that fire most, and loosen only those that past tickets show over-escalate.
C. Let the model's confidence alone decide every route.
D. Raise the refund limit to $2,000 so fewer tickets qualify.

**Answer:** B. Measure before you change anything. Loosen only the rules that past tickets prove are too strict. Missed fraud and money cases are the expensive mistake.

## Can you answer these from memory?

**Flash cards**

- **What is a ticket-triage agent?** An AI app that labels and routes support tickets, and hands risky ones to a person.
- **Who decides the route?** Code. The model labels the ticket, and fixed rules in code pick the queue.
- **Name three always-human triggers.** Fraud, legal threats, and payouts or refunds above a set limit.
- **Why is ticket text risky?** Customers can type instructions into it, so it is untrusted input.
- **What is shadow mode?** The agent labels tickets while people still act, so you can compare before it goes live.
- **What goes in a handoff packet?** A summary, what the agent checked, and a suggested next step.

## Likely follow-up questions

- Q172 When and how do you add a human in the loop? https://designervenkat.online/interview/ai/human-in-the-loop-for-ai-agents
- Q194 How do you design stop conditions? https://designervenkat.online/interview/ai/how-do-you-design-stop-conditions
- Q366 Design human approval for risky agent actions. (full answer coming)
- Q201 What is prompt injection? https://designervenkat.online/interview/ai/what-is-prompt-injection
- Q173 How do you stop endless agent loops? https://designervenkat.online/interview/ai/how-do-you-stop-endless-agent-loops
- Q198 How do you roll out a new agent version safely? (full answer coming)

## Learn it in depth

- [AI Agents](https://designervenkat.online/learn/ai-engineering/ai-agents)
- [Agentic AI security](https://designervenkat.online/learn/ai-guardrails/agentic-ai-security)
