Build an AI Agent That Triages and Diagnoses Incoming Tickets
System DesignModel answerLast updated
Design an LLM-driven agent that triages tickets, gathers operational evidence, proposes a root cause and fix, and acts only within strict human-approval and safety boundaries.
Your organization receives a steady stream of support requests, on-call pages, and bug reports. You are asked to design an AI-driven agent that investigates each one with little manual effort.
For every incoming ticket, the system should:
- Interpret the reporter's problem from the ticket text and any attachments.
- Assign a category, an owning team, and a priority, and recognize duplicates.
- Pull supporting evidence from internal sources: logs, metrics, traces, documentation, runbooks, deployment and config history, and earlier incidents.
- Propose a most likely root cause, ideally with alternatives ranked by confidence.
- Recommend a fix, an escalation route, or another next step.
- Carry out low-risk remediation automatically when policy permits.
- Require human sign-off for anything risky.
In your answer, cover:
- Requirements and assumptions, including volume, latency targets, and cost per ticket.
- The agent's reasoning loop and when it stops.
- Overall architecture and how tools are integrated.
- How evidence is retrieved and kept within the model's context limits.
- Safety controls, including action tiers and defenses against malicious ticket content.
- How you would evaluate quality offline and monitor the system in production.
State your assumptions explicitly and justify the trade-offs you make.
Hints
Hint 1
Separate the investigation (read-only, safe to automate broadly) from the action (side effects, needs gating). Different parts deserve different levels of autonomy.
Hint 2
A fixed investigation skeleton (scope, gather baseline evidence, form hypotheses, test the cheapest discriminating query, conclude) is usually more reliable than a free-form loop. Keep hypotheses and evidence in structured state instead of the raw chat history.
Hint 3
Route every tool call through a single gateway that enforces schemas, scoped credentials, rate limits, redaction, and audit logging. Treat ticket and log text as untrusted input that can never expand permissions.
Hint 4
For evaluation, build a replayable set of past tickets with human-verified root causes, and score triage accuracy, root-cause correctness, evidence quality, and cost. Then watch override rates and drift in production.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
1. Requirements and assumptions
Functional
- Ingest tickets from support queues, paging systems, and bug trackers.
- Triage: category, owner, severity, duplicate detection.
- Investigate using logs, metrics, traces, deploy history, docs, runbooks, and past incidents.
- Emit ranked hypotheses with cited evidence, a confidence score, and a recommended next step.
- Execute only allowlisted remediations; gate risky ones behind human approval.
Assumptions
- Around 50k tickets/day, peaking near 5/s, with up to 10x bursts when one outage generates many duplicates.
- Latency: triage under 30 s; high-severity diagnosis under 5 min; low-priority work can queue for up to 30 min.
- Budget: roughly 10-25 tool calls and 50-150k tokens per investigation, averaging under $0.50, with extra spend reserved for high severity.
- Every step auditable and replayable; least-privilege data access.
2. Architecture
- Ingestion and dedup. Tickets land on a queue. An embedding similarity check against open tickets for the same service within a short window attaches duplicates to an existing investigation. This protects both cost and the model during outages.
- Triage service. A small fine-tuned classifier plus rules handles category, owner, and severity. The LLM is a fallback for low-confidence cases. It runs on every ticket, so it must be cheap.
- Orchestrator. A durable workflow engine checkpoints after each step, so crashes do not lose work and runs can be replayed for debugging and evaluation.
- Tool gateway. The only path to external systems. It provides typed schemas, scoped credentials, rate limits, timeouts, result truncation and summarization, PII redaction, and audit logs.
- Retrieval service. Hybrid lexical plus embedding search over runbooks, docs, and postmortems, with a structured index of past incidents keyed by service, error signature, and symptoms.
- Policy engine and executor. Classifies each proposed action by risk tier and either executes it or routes it for approval.
- Review UI. Presents the evidence trail and hypotheses with approve, reject, and edit controls.
- Feedback store. Captures verified root causes and resolutions as evaluation and training data.
State machine: TRIAGED -> INVESTIGATING -> DIAGNOSED -> AWAITING_APPROVAL -> RESOLVED or ESCALATED.
3. The agent loop
Use a structured loop, because debugging has a known shape.
- Scope: extract service, region, time window, and error signatures.
- Baseline evidence, in parallel: recent deploys and config changes, golden-signal metrics versus the prior week, top error signatures, similar past incidents.
- Hypothesize: 3-5 candidates (bad deploy, dependency failure, capacity, data issue, user error), each with a prior.
- Test: for each, run the cheapest discriminating query (does onset align with a deploy? is a dependency's error rate elevated?) and update confidence.
- Stop when the top hypothesis passes a confidence threshold with at least two independent evidence types, when the budget runs out, or when a data source is blocked.
- Conclude: diagnosis, citations, recommendation, escalation target. If confidence is low, say so and hand off with the gathered evidence; a good handoff is still valuable.
Keep hypotheses and evidence in a structured scratchpad instead of the raw transcript. This bounds context growth and makes reasoning inspectable.
4. Tools, retrieval, and context
- Tools should return aggregates, not raw data: top-k error clusters with counts, anomaly summaries from change-point detection, trace critical paths. The model drills down by ID when needed.
- Prefer deterministic analytics (deploy-time correlation, anomaly detection) over asking the LLM to read numbers.
- Postmortems are the highest-value corpus. Combine structured filters with symptom embeddings and re-rank by recency and service-graph proximity.
- Ground recommended steps in retrieved runbook text rather than generated instructions.
5. Safety
| Tier | Examples | Policy |
|---|---|---|
| 0 Read-only | queries, log search | Automatic |
| 1 Reversible, small blast radius | restart one pod, clear a cache key, rerun a job | Automatic if allowlisted, with dry run and rollback check |
| 2 Service-impacting | roll back a deploy, flip a flag, scale down | Human approval |
| 3 Destructive or data-affecting | DB writes, deletes, permission changes | Never automated; recommend only |
Further controls:
- Prompt injection: ticket text and log lines are untrusted data. Permissions come from the policy engine, never from model output, and ticket content cannot widen scope.
- Scoped credentials per investigation.
- Action rate limits and circuit breakers (for example, a cap on restarts per service per hour), plus a global kill switch.
- Full audit trail linking each action to its evidence and approver.
6. Evaluation
Offline
- Build a replay set of historical tickets with human-verified root causes, with tool outputs snapshotted at ticket time to avoid leakage from later data.
- Metrics: triage accuracy and severity under-triage rate (the costly error), top-1 and top-3 root-cause accuracy, evidence faithfulness (are citations real and supportive?), recommendation correctness, tool calls, tokens, and latency.
- Use an LLM judge for open-ended quality, calibrated against human labels.
- Include adversarial cases: injected instructions in tickets, missing data, conflicting signals.
Online
- Run in shadow mode first, then suggest-only, then limited auto-remediation for Tier 1.
- Track human override rate, time to resolution, escalation rate, reopen rate, and confidence calibration (does 80% confidence mean about 80% correct?).
- A/B test prompt and model changes on a traffic slice.
7. Production monitoring
- Per-step latency, tool error rates, token spend, and budget exhaustion rate.
- Drift in ticket mix, retrieval hit quality, and calibration.
- Alerts on spikes in blocked actions, policy violations, or injection detections.
- A feedback loop that turns verified outcomes into new eval cases and retraining data.
Trade-offs and common mistakes
- Fully free-form agent versus structured loop: the latter is more predictable and cheaper, at some cost in flexibility.
- Larger model everywhere versus small classifier plus LLM fallback: the tiered approach controls cost at volume.
- Common mistakes: dumping raw logs into context, letting the model decide its own permissions, ignoring duplicate storms, reporting confidence without calibrating it, and skipping the handoff path when confidence is low.