This prompt is designed for reliability engineers and AI operations teams who need to classify AI system failures into a defined taxonomy before routing them to the correct human review queue. The job-to-be-done is not just to detect that something went wrong, but to produce a structured, diagnostic classification that determines who should handle the issue, how urgently, and what context they need. Use this when your production AI pipeline generates errors, unexpected outputs, or anomalous behaviors that require human triage, and you need a consistent, machine-readable classification to drive automated escalation logic.
Prompt
Failure Mode Classification Prompt for Escalation Routing

When to Use This Prompt
Define the job, reader, and constraints for the Failure Mode Classification Prompt for Escalation Routing.
The ideal user is an engineer integrating this prompt into an incident management or observability platform. The required context includes the raw model input, the model's output or error trace, any tool-call logs, and the expected behavior. The prompt works best when you have a pre-defined failure taxonomy (e.g., 'hallucination', 'refusal', 'tool_error', 'format_violation', 'policy_boundary') and a set of routing destinations (e.g., 'review_queue_urgent', 'review_queue_standard', 'auto_resolve'). The prompt's value is in its consistency: it forces every failure to be tagged with a root cause category, a severity level, and a recommended response, which prevents ad-hoc triage and ensures that high-severity issues like silent failures or policy violations are not lost in a general support queue.
Do not use this prompt as a substitute for a real-time monitoring dashboard or as the sole arbiter of whether to page an on-call engineer. It is a classification step within a larger escalation pipeline, not a replacement for metric-based alerting. Avoid using it for failures that are already well-understood and can be handled by deterministic retry logic or output repair prompts. The prompt is also not designed for user-facing explanations; its output is structured for machine consumption and internal routing. Before deploying, ensure you have a human review process mapped to each classification label and a feedback loop to validate the prompt's accuracy against postmortem root cause labels.
Use Case Fit
Where this prompt works and where it does not. Understand the operational boundaries before wiring it into your escalation pipeline.
Good Fit: Postmortem-Driven Taxonomy
Use when: you have a defined failure taxonomy derived from real postmortems or incident retrospectives. The prompt excels at matching production failures to known root cause categories. Guardrail: validate the taxonomy is current before each run; stale categories cause misclassification.
Bad Fit: Novel Failure Discovery
Avoid when: you need the model to discover new failure modes not in your taxonomy. This prompt classifies into existing buckets—it will force-fit novel failures into wrong categories. Guardrail: pair with a novelty detection prompt upstream to catch unknown patterns before classification.
Required Inputs
Must have: the failure incident description, the AI's output or action that failed, expected behavior, and the defined taxonomy with category definitions. Guardrail: missing expected behavior leads to ambiguous classification; require it in the input schema and reject incomplete submissions.
Operational Risk: Taxonomy Drift
What to watch: failure patterns shift as your system evolves, but the prompt's taxonomy stays static. Classification accuracy degrades silently over weeks or months. Guardrail: schedule monthly taxonomy reviews against recent postmortems and track classification confidence trends.
Operational Risk: Severity Miscalibration
What to watch: the model assigns severity levels inconsistently, especially for edge cases that blend multiple failure categories. Low-severity mislabels delay critical escalations. Guardrail: implement a severity override path for human reviewers and audit severity distributions weekly for anomalies.
Not a Replacement for Root Cause Analysis
Avoid when: you need definitive root cause. This prompt classifies symptoms and failure patterns—it does not trace causality through your stack. Guardrail: treat the output as a routing label and diagnostic starting point, not a completed investigation. Always link to the full incident record.
Copy-Ready Prompt Template
A reusable prompt template for classifying AI system failures into a defined taxonomy and routing them to the correct escalation queue with severity and diagnostic context.
This prompt template is designed to be dropped into an escalation workflow immediately after a failure event is captured. It expects structured input describing the failure, a defined taxonomy of failure modes, and a set of available review queues. The model's job is to classify the failure, assign a severity, and produce a routing decision with enough context for a human reviewer to act without re-investigating the root cause from scratch.
textYou are a failure mode classifier for an AI production system. Your task is to analyze a failure event, classify it into a predefined taxonomy, and route it to the correct human review queue. ## INPUT Failure Event: [FAILURE_EVENT] System Context: [SYSTEM_CONTEXT] ## FAILURE MODE TAXONOMY [FAILURE_TAXONOMY] ## AVAILABLE REVIEW QUEUES [REVIEW_QUEUES] ## OUTPUT SCHEMA Return a single JSON object with the following fields: { "classification": { "primary_mode": "<exact taxonomy label>", "secondary_modes": ["<additional contributing modes>"], "confidence": <0.0 to 1.0>, "rationale": "<brief explanation of why this classification was chosen>" }, "severity": { "level": "<CRITICAL | HIGH | MEDIUM | LOW>", "impact_description": "<what was affected and how severely>", "user_visible": <true | false> }, "routing": { "primary_queue": "<exact queue name from available queues>", "secondary_queue": "<fallback queue or null>", "urgency": "<immediate | same_day | next_business_day | informational>", "required_context": ["<list of evidence or artifacts the reviewer will need>"] }, "diagnostic_summary": "<one-paragraph summary of what happened, suitable for a reviewer reading this cold>" } ## CONSTRAINTS - Use only taxonomy labels exactly as written. Do not invent new categories. - If the failure does not clearly match any taxonomy entry, set primary_mode to "UNCLASSIFIED" and confidence below 0.5. - For CRITICAL severity, urgency must be "immediate". - If user_visible is true, include the user-facing symptom in the diagnostic_summary. - Do not recommend actions outside the available review queues. - If multiple modes apply, list the dominant one as primary and up to two contributing modes as secondary. ## EXAMPLES [EXAMPLES]
To adapt this template, replace each square-bracket placeholder with your system's specific taxonomy, queue definitions, and example failure cases. The taxonomy should be a flat or hierarchical list of failure modes your team has observed or anticipates—such as HALLUCINATION_FACTUAL, TOOL_CALL_MALFORMED, REFUSAL_OVERBROAD, or LATENCY_TIMEOUT. The review queues should map to actual teams or individuals with clear ownership. Before deploying, run this prompt against a golden set of 20–50 known failures with postmortem root cause labels and measure classification accuracy. If accuracy on primary_mode falls below 90%, add more few-shot examples covering the misclassified patterns rather than lengthening the instructions.
Prompt Variables
Required inputs for the Failure Mode Classification Prompt. Each placeholder must be populated before the prompt is assembled and sent. Validation notes describe how to programmatically check that the input is well-formed before incurring inference cost.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[FAILURE_LOG] | The raw error log, stack trace, or incident description that triggered the escalation | TimeoutError: Connection to payment service timed out after 30s at gateway-prod-3 | Must be non-empty string. Check length < 8000 tokens to avoid context truncation. Reject null or whitespace-only input. |
[SYSTEM_CONTEXT] | Metadata about the system state when the failure occurred: service name, environment, deployment version, recent changes | service: payment-gateway, env: production, version: v2.4.1, last_deploy: 2025-03-15T14:22:00Z | Must contain at minimum service name and environment. Parse as JSON or key-value pairs. Fail if required keys are missing. |
[FAILURE_TAXONOMY] | The defined set of failure categories the model must choose from, with descriptions and severity defaults | TAXONOMY: {categories: [{id: 'timeout', description: 'External dependency timeout', default_severity: 'P2'}, {id: 'auth_failure', description: 'Authentication or authorization error', default_severity: 'P1'}]} | Must be valid JSON array with at least one category. Each category must have id, description, and default_severity fields. Validate schema before prompt assembly. |
[ESCALATION_QUEUES] | The available review queues with routing rules, SLAs, and team assignments | QUEUES: [{queue_id: 'oncall-payments', team: 'payments-squad', sla_minutes: 15, severity: ['P1','P2']}, {queue_id: 'triage-general', team: 'sre', sla_minutes: 60, severity: ['P3','P4']}] | Must be valid JSON array with at least one queue. Each queue must have queue_id and team. Validate that severity values match taxonomy severity levels. |
[HISTORICAL_POSTMORTEMS] | Reference examples of past failures with confirmed root cause labels for few-shot grounding | POSTMORTEM: {failure: 'DB connection pool exhaustion', category: 'resource_exhaustion', severity: 'P1', queue: 'oncall-database'} | Optional but strongly recommended. If provided, must be valid JSON array of objects with failure, category, severity, and queue fields matching taxonomy and queue definitions. Null allowed if no historical data exists. |
[OUTPUT_SCHEMA] | The exact JSON schema the model must produce, including required fields and enum constraints | SCHEMA: {type: 'object', required: ['category','severity','queue','confidence','rationale','recommended_action'], properties: {category: {enum: ['timeout','auth_failure','resource_exhaustion']}}} | Must be valid JSON Schema. Required fields must include category, severity, queue, confidence, rationale, and recommended_action. Enum values must match taxonomy category IDs and queue IDs. Validate with JSON Schema validator before prompt assembly. |
[CONFIDENCE_THRESHOLD] | The minimum confidence score required for automatic routing; below this threshold the item is flagged for human triage override | 0.75 | Must be a float between 0.0 and 1.0. Default to 0.7 if not specified. Reject values outside range. Used post-generation to decide whether classification is accepted or escalated to manual review. |
[MAX_RETRIES] | The number of classification attempts allowed before forcing human review | 3 | Must be a positive integer. Default to 2 if not specified. Used by the harness to control retry loop. Reject zero or negative values. |
Implementation Harness Notes
How to wire the Failure Mode Classification Prompt into a production escalation pipeline with validation, retries, and routing logic.
This prompt is designed to sit at the critical junction between an AI system's failure event and the human review queue. It should be invoked immediately after a failure is detected—whether from a tool error, a guardrail violation, a low-confidence output, or an explicit agent crash. The prompt's job is to classify the failure into a predefined taxonomy and produce a structured routing decision, not to diagnose the root cause or fix the problem. The implementation harness must treat this as a synchronous classification step: the upstream system calls the model, receives the classification payload, and then uses the severity and recommended_queue fields to place the incident into the correct review bucket. Do not use this prompt for real-time intervention; it is a post-failure triage tool.
To wire this into an application, wrap the prompt in a function that accepts a failure_context object containing the raw error, the agent's last state, the user input, and any tool outputs. The function should construct the prompt by injecting these fields into the [FAILURE_CONTEXT] placeholder, along with the [FAILURE_TAXONOMY] that defines your organization's specific failure categories. After calling the model, validate the output against a strict JSON schema that requires failure_class, severity (e.g., CRITICAL, HIGH, MEDIUM, LOW), recommended_queue, and diagnostic_summary. If validation fails, retry once with the validation error appended to the prompt as a [CONSTRAINT] reminder. Log every classification attempt—including validation failures—to your observability platform so you can track classification accuracy against postmortem root cause labels over time. For high-severity classifications (CRITICAL or HIGH), bypass the normal queue and trigger an immediate alert to the on-call channel with the diagnostic_summary included.
Model choice matters here. Use a model with strong instruction-following and JSON mode support, such as gpt-4o or claude-3-5-sonnet, and set temperature=0 to maximize classification consistency. If your failure taxonomy is large or domain-specific, provide 3–5 few-shot examples in the [EXAMPLES] placeholder showing correct classifications for common failure patterns in your system. Do not use this prompt with small or general-purpose models that may hallucinate taxonomy categories. The next step after implementation is to build an eval harness that compares the prompt's classifications against a golden dataset of failures with known root causes, measuring precision and recall per failure class. This eval should run on every prompt change before deployment.
Expected Output Contract
Defines the structured JSON payload the model must return for each failure classification. Use this contract to validate outputs before routing to review queues.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
failure_id | string (UUID v4) | Must parse as valid UUID v4; reject on format mismatch | |
classification | enum string | Must exactly match one label from [TAXONOMY]; reject unknown values | |
severity | enum string | Must be 'critical', 'high', 'medium', or 'low'; case-sensitive check | |
confidence | number (0.0–1.0) | Must be float within [0.0, 1.0]; escalate to human if below [CONFIDENCE_THRESHOLD] | |
root_cause_summary | string (≤ 280 chars) | Must be non-empty and ≤ 280 characters; reject empty or over-length | |
evidence_excerpts | array of strings | Must be a non-empty array; each string ≤ 500 chars; reject if empty or any item exceeds limit | |
recommended_queue | enum string | Must match one queue from [QUEUE_MAP]; reject unknown queues | |
requires_immediate_attention | boolean | Must be true or false; reject null or string values | |
diagnostic_context | object | If present, must contain valid JSON with keys from [DIAGNOSTIC_SCHEMA]; null allowed |
Common Failure Modes
Failure mode classification prompts break when the taxonomy is too rigid, the context is too thin, or the model defaults to the most common bucket. These cards cover the most frequent failure patterns and how to guard against them before they reach a human reviewer.
Taxonomy Collapse to Majority Class
What to watch: The model over-uses the most frequent failure category (e.g., 'hallucination') and ignores rarer but critical classes (e.g., 'tool misuse' or 'policy boundary violation'). This skews routing and hides emerging failure patterns. Guardrail: Include few-shot examples for each class proportional to their operational severity, not their frequency. Add a post-classification check that flags when a single class exceeds 70% of recent outputs.
Insufficient Diagnostic Context
What to watch: The prompt classifies the failure correctly but the escalation payload lacks the evidence the reviewer needs to act—missing the original input, tool call trace, or model reasoning. Reviewers reject or rework the ticket. Guardrail: Require the prompt to output a structured diagnostic_blob field with the full input, model output, expected behavior, and relevant trace excerpt. Validate that the field is non-empty and exceeds a minimum token length before routing.
Severity Inflation or Deflation
What to watch: The model assigns critical severity to minor formatting errors or low severity to silent data corruption. Misclassified severity breaks SLA-based routing and erodes trust in the automation. Guardrail: Anchor severity definitions with concrete, measurable criteria (e.g., 'critical = user data loss or security boundary breach'). Include a severity calibration example for each level and run periodic audits comparing model-assigned severity to postmortem root cause labels.
Novel Failure Class Blindness
What to watch: A new failure mode emerges in production (e.g., a new model version introduces a unique refusal pattern) but the classifier forces it into an existing bucket because the taxonomy is closed. The operations team never sees the new pattern. Guardrail: Add an 'unclassified' bucket with a required novel_pattern_description field. Route unclassified items to a dedicated review queue and schedule a weekly taxonomy review to promote persistent novel patterns into named classes.
Prompt Injection Masquerading as Legitimate Failure
What to watch: An adversarial input triggers a failure that the classifier attributes to a benign root cause (e.g., 'context confusion') when the real cause is a prompt injection attempt. The escalation goes to the wrong team and the injection vector remains unpatched. Guardrail: Run a separate injection screening prompt before failure classification. If the injection score exceeds threshold, override the failure taxonomy with 'adversarial_input' and route directly to the security review queue with the injection pattern highlighted.
Root Cause vs. Symptom Confusion
What to watch: The model classifies the surface symptom (e.g., 'malformed JSON output') rather than the underlying cause (e.g., 'tool returned unexpected schema'). The reviewer fixes the output but the root cause recurs. Guardrail: Structure the prompt to require both a symptom label and a root_cause label with a causal chain explanation. Validate that the two labels differ when the symptom is a downstream effect. Use few-shot examples that demonstrate tracing symptoms back to upstream triggers.
Evaluation Rubric
Use this rubric to evaluate the Failure Mode Classification Prompt before shipping. Each criterion targets a specific failure mode that degrades escalation routing quality. Run these tests against a golden dataset of 50+ labeled postmortem root causes to ensure classification accuracy and routing precision.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Taxonomy Adherence | Classification label matches exactly one value from the defined failure taxonomy enum; no invented or hybrid categories | Output contains a label not present in the allowed taxonomy list or concatenates multiple categories into a single field | Schema validation: parse output JSON, extract classification field, assert membership in allowed enum set for all 50 test cases |
Severity Calibration | Severity score aligns with postmortem ground truth within ±1 level on a 5-point scale for at least 90% of cases | Severity is consistently inflated by 2+ levels on low-impact failures or deflated on critical incidents | Ordinal regression check: compute mean absolute error between predicted severity and ground truth severity across the golden dataset |
Routing Queue Accuracy | Recommended review queue matches the postmortem-assigned team or escalation path for at least 85% of test cases | High-severity security failures routed to general review queue instead of security incident queue | Confusion matrix: compare predicted queue against ground truth queue label, measure per-queue precision and recall, flag any queue with recall below 0.80 |
Diagnostic Context Completeness | Output includes all required diagnostic fields: failure summary, affected component, observed symptom, and confidence score | Missing required field or null value in a non-nullable field such as failure summary or affected component | Schema completeness check: validate all required fields are present and non-null for every test case output |
Confidence Score Honesty | Confidence score is below 0.70 when the classification is incorrect and above 0.80 when correct for at least 80% of cases | High confidence scores on misclassified failures indicate overconfidence and mask routing errors | Calibration plot: bin predictions by confidence decile, measure accuracy per bin, flag if any bin above 0.80 confidence has accuracy below 0.85 |
Edge Case Handling | Prompt correctly classifies or escalates novel failure modes not seen in few-shot examples without hallucinating a known category | Novel failure mode forced into an existing taxonomy bucket with high confidence instead of flagged as unclassified or escalated | Hold-out test: include 10 novel failure modes in test set, verify output either uses an unclassified label or confidence score below 0.60 |
Response Format Consistency | Output is valid JSON matching the defined schema on 100% of test cases with no parsing errors | Malformed JSON, extra text outside JSON block, or field type mismatch causes downstream routing failure | Automated parse test: run JSON.parse on every output, validate against JSON Schema, count parse failures across all test cases |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Start with the base taxonomy and a single model call. Use a simple structured output request without strict schema enforcement. Focus on getting the classification logic right before adding routing rules.
codeClassify the following failure into one of these categories: - Hallucination - Tool Error - Refusal - Format Error - Other Failure description: [FAILURE_DESCRIPTION]
Watch for
- Category bleed where the model invents subcategories not in your taxonomy
- Missing severity field if you later need prioritization
- No confidence signal, making it hard to decide when to escalate

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us