AI Agents · Ai

AI Agent for Case Routing and Triage

AI Agent for Case Routing and Triage is the work that defines the next phase of enterprise software. ERP systems hold the most valuable business data in the company — customers,.

John Kihiu12 min read

Case routing is a classification-plus-priority problem before it is anything else, and that framing keeps the AI agent honest. Given an inbound support case — subject, body, customer account, product line, historical ticket volume for that customer — the agent has to pick a queue, set a priority, and often tag the likely root cause, all before a human reads it. Done well, that shaves the 10-20 minutes a triage lead spends re-reading and re-routing every misfiled case; done badly, it silently drops urgent cases into the wrong queue where they sit until someone notices.

Why this is a classification problem, not a chat problem

The temptation is to hand the case text to an LLM and ask "what should I do with this?" in free text. That produces plausible-sounding answers that don't map cleanly onto your actual queue structure, and it's hard to evaluate at scale. The better design treats routing as structured output: the model calls a single route_case tool with an enum of valid queue IDs, a priority level, and a confidence score, constrained by function-calling schemas so the response is always parseable. Anthropic's tool-use API and OpenAI's function calling both support this — the model doesn't choose free text, it fills in the arguments of a function you defined.

Confidence score is the field that makes the difference between a toy and a production system. Below a threshold — say 0.7 — the case falls back to a human triage queue with the model's reasoning attached as a suggestion, not an action. Above it, the routing applies automatically. You tune that threshold against measured accuracy, not intuition.

What context the agent actually needs

A raw case description is rarely enough to route well. The agent needs the customer's tier (an enterprise account escalates differently than a trial account), open case history (a fourth case about the same issue this month is a different priority than a first-time report), and product/module metadata pulled from the ERP or CRM record. This is where retrieval comes in: rather than stuffing the entire case history into the prompt, embed past case summaries and retrieve the 3-5 most similar prior cases via vector search, then include only those plus structured account fields pulled directly from the database.

Retrieval beats memory

Don't try to keep a running conversational memory of every case a customer has ever filed. Pull what's relevant per-request from a vector store or SQL query. It's cheaper in tokens, easier to audit, and doesn't drift as the account's history grows.

Designing the routing tool schema

The schema is the actual product here — get it wrong and every downstream decision inherits the mistake. Queue IDs should be a closed enum pulled from your live queue configuration, not free text the model invents. Priority should map to your existing SLA tiers. And the schema should require a short justification string, which does double duty: it's what a human reviewer scans when confidence is low, and it's what you log for auditing why a case landed where it did.

JSON · TOOL SCHEMA
{
  "name": "route_case",
  "description": "Assign a support case to a queue and priority",
  "input_schema": {
    "type": "object",
    "properties": {
      "queue_id": {
        "type": "string",
        "enum": ["billing", "technical", "onboarding", "escalations"]
      },
      "priority": {
        "type": "string",
        "enum": ["low", "normal", "high", "urgent"]
      },
      "confidence": {
        "type": "number",
        "minimum": 0,
        "maximum": 1
      },
      "justification": { "type": "string", "maxLength": 280 }
    },
    "required": ["queue_id", "priority", "confidence", "justification"]
  }
}

Human-in-the-loop for the cases that matter

Not every misroute is equally costly. A billing question routed to technical support costs a few minutes of reassignment. A security-incident report routed to a low-priority general queue can cost hours. Rather than a single global confidence threshold, weight the threshold by the downside: cases mentioning keywords like "data breach," "payment failed," or "cannot access" from an enterprise account should require human confirmation regardless of the model's confidence score. This is a cheap rule-based override sitting in front of the LLM decision, not a second model call.

Don't let the agent close cases

Routing and prioritizing are reversible, low-risk actions. Closing a case or issuing a refund is not. Keep the agent's authority scoped to routing decisions and require a human to take any action that can't be cheaply undone.

Measuring routing accuracy over time

You need a held-out evaluation set — a few hundred historical cases with their correct queue and priority already known from what actually happened — and you re-run it every time you touch the prompt or the underlying model. Track precision per queue, not just overall accuracy, because a model that's 95% accurate but consistently misroutes escalations is worse than one that's 90% accurate uniformly. Log every routing decision with its confidence score and eventual human override (if any); overridden decisions are your ongoing training signal for adjusting the confidence threshold and catching drift after a model version change.

SignalUsed for
Confidence scoreAuto-route vs. human review gate
Keyword/account override rulesForce review on high-stakes cases regardless of confidence
Retrieved similar casesGrounding without stuffing full history into context
Human override logOngoing accuracy measurement and threshold tuning

Wrapping up

Case routing is one of the safer places to start with agentic automation because the action is reversible and the failure mode is annoyance rather than financial loss. Keep the model's job narrow — classify and score confidence — back it with real account context via retrieval, and let simple override rules catch the cases where being wrong is expensive. That combination gets you most of the time savings without needing the agent to be right 100% of the time.

John Kihiu
Acumatica ERP Developer · Laravel Engineer

Independent software engineer in Nairobi specialising in Acumatica customisations, Laravel backends, and tax fiscalisation integrations across East and Southern Africa.