This prompt is designed for orchestration systems that detect an agent has failed the same task or task type repeatedly. Instead of letting the agent loop indefinitely or silently dropping the work, this prompt produces a structured escalation package. It aggregates failure patterns across attempts, identifies the most likely root cause, and recommends a concrete resolution path: reassign to a different agent, redesign the task or agent instructions, or escalate permanently to a human operator. Use this when your retry budget is exhausted and you need a decision, not another attempt.
Prompt
Escalation Prompt for Repeated Agent Failures

When to Use This Prompt
Defines the operational trigger for the escalation prompt: exhausted retries requiring a structured decision, not another attempt.
The ideal user is an AI platform engineer or orchestration developer building a supervisor or controller agent that monitors worker agents. The required context includes the original task definition, the agent's role and capabilities, a log of each failed attempt with error traces, and the retry policy that was exhausted. This prompt is not for single-attempt failures, transient errors that a retry with backoff would resolve, or cases where the failure is clearly a tool outage that should be handled by infrastructure alerting. Do not use this prompt when the agent's output is non-deterministic and a simple majority-vote across parallel runs would suffice.
Before wiring this prompt into your system, define clear thresholds: maximum retry count, maximum wall-clock time, and a circuit-breaker for cascading failures. The prompt's value is in forcing a structured root-cause analysis and a concrete recommendation rather than producing another opaque failure log. After receiving the escalation output, your harness should log the decision, update the task state, and route to the recommended resolution path—not simply retry again. For high-risk domains such as finance or healthcare, always require human review of the escalation recommendation before automated reassignment or redesign actions are executed.
Use Case Fit
Where the escalation prompt for repeated agent failures works and where it introduces new risks. Use these cards to decide if this prompt fits your orchestration architecture.
Good Fit: Persistent Task Failures
Use when: An agent has failed the same task across multiple retries with consistent error patterns. Guardrail: The prompt aggregates failure traces into a structured root-cause hypothesis, preventing the orchestrator from retrying indefinitely.
Good Fit: Multi-Agent Pipelines
Use when: A specialized agent in a chain repeatedly fails, and the orchestrator needs to decide whether to reassign, redesign, or escalate. Guardrail: The prompt includes agent identity and task contract in the escalation payload so reviewers understand capability boundaries.
Bad Fit: Transient Errors
Avoid when: Failures are caused by temporary network issues, rate limits, or timeouts that resolve on retry. Guardrail: Implement a retry budget and backoff strategy before invoking escalation; the prompt should only fire after the budget is exhausted.
Bad Fit: Ambiguous Success Criteria
Avoid when: The orchestrator cannot reliably determine task success or failure because output evaluation is subjective or undefined. Guardrail: Define a structured success validator with pass/fail criteria before wiring this prompt into the escalation path.
Required Inputs
Risk: Incomplete escalation context leads to misdiagnosis and unnecessary human intervention. Guardrail: The prompt requires the original task definition, failure traces from each attempt, agent identity, retry count, and any partial outputs produced.
Operational Risk: Alert Fatigue
Risk: Repeated escalations for the same root cause flood human reviewers with duplicate alerts. Guardrail: Implement deduplication logic that groups escalations by failure signature and suppresses repeats within a configurable window.
Copy-Ready Prompt Template
A reusable escalation prompt with square-bracket placeholders that aggregates repeated agent failures, identifies root causes, and recommends resolution paths.
This prompt template is designed to be injected into your orchestration layer when a monitoring system detects that an agent has failed the same task or task type beyond a configured threshold. It consumes structured failure logs, not raw agent traces, and produces an escalation payload that a human operator or a supervisor agent can act on. The template uses square-bracket placeholders for all variable inputs, making it safe to paste directly into your prompt assembly code. Populate these placeholders from your agent execution logs, error telemetry, and task definitions before sending the request to the model.
textYou are an escalation analyst for a multi-agent orchestration system. Your job is to review repeated agent failures, identify the most likely root cause, and recommend a resolution path. ## FAILURE CONTEXT - **Failing Agent ID:** [AGENT_ID] - **Agent Role:** [AGENT_ROLE_DESCRIPTION] - **Task Type:** [TASK_TYPE] - **Task Description:** [TASK_DESCRIPTION] - **Failure Threshold:** [FAILURE_COUNT] failures within [TIME_WINDOW] ## FAILURE LOG Below is a structured log of each failure attempt. Each entry includes the attempt number, timestamp, error code, error message, and a summary of the agent's state at failure time. [FAILURE_LOG_ENTRIES] ## AGENT CAPABILITY BOUNDARY [AGENT_CAPABILITY_DEFINITION] ## AVAILABLE ESCALATION PATHS [ESCALATION_PATH_OPTIONS] ## OUTPUT SCHEMA Return a JSON object with the following structure: { "escalation_id": "string, unique identifier for this escalation", "failure_pattern": "string, categorized pattern: TRANSIENT_ERROR | CAPABILITY_GAP | INPUT_MALFORMATION | DEPENDENCY_FAILURE | POLICY_BLOCK | AMBIGUITY_LOOP | OTHER", "root_cause_assessment": "string, concise explanation of the most likely root cause based on the failure log", "supporting_evidence": ["string, specific failure log entry or pattern that supports the root cause assessment"], "recommended_action": "string, one of: RETRY_WITH_FIX | REASSIGN_TO_AGENT:[agent_id] | REDESIGN_TASK | ESCALATE_TO_HUMAN | DISABLE_TASK | NO_ACTION", "action_rationale": "string, why this action is recommended given the failure pattern and agent capability boundary", "handoff_package": { "summary_for_reviewer": "string, human-readable summary of what happened and what is needed", "pending_decisions": ["string, specific questions a human reviewer must answer"], "blocked_dependencies": ["string, any upstream systems or data that are blocking resolution"] }, "confidence": "string, LOW | MEDIUM | HIGH indicating confidence in the root cause assessment", "requires_human_approval": "boolean, true if the recommended action should not be executed without human review" } ## CONSTRAINTS - Do not fabricate failure details not present in the failure log. - If multiple failure patterns are present, select the dominant one and note others in the root cause assessment. - If the failure log is incomplete or contradictory, set confidence to LOW and require human approval. - For any recommended action that modifies agent configuration or disables a task, set requires_human_approval to true. - If the failure pattern is POLICY_BLOCK, do not recommend workarounds that violate the policy.
To adapt this template, start by mapping your agent telemetry to the placeholders. [FAILURE_LOG_ENTRIES] should be a structured array of failure records, not raw stack traces—each entry needs an attempt number, timestamp, error code, error message, and a brief state summary. [AGENT_CAPABILITY_DEFINITION] should come from your agent's role specification or system prompt, describing what the agent is authorized and equipped to do. [ESCALATION_PATH_OPTIONS] should list the concrete paths available in your system, such as specific agent IDs for reassignment, human review queues, or task redesign workflows. The output schema is designed to be machine-readable so your orchestrator can parse the JSON and route the escalation automatically, but the handoff_package field ensures a human reviewer gets a readable summary without needing to inspect raw logs.
Before deploying this prompt, validate that your failure log entries contain enough signal for pattern detection. A log with only generic error codes like 'agent failed' will produce low-confidence escalations. Instrument your agents to capture categorized error codes, the input that triggered the failure, and any tool or dependency failures. Wire the prompt into a retry-aware escalation path: the orchestrator should only invoke this prompt after the agent has exhausted its configured retry budget, not on the first failure. For high-risk domains such as finance or healthcare, set requires_human_approval to true unconditionally in your harness logic, overriding the model's output if necessary.
Common failure modes for this prompt include: the model defaulting to ESCALATE_TO_HUMAN for every case because the failure log lacks sufficient detail; misclassifying a dependency failure as an agent capability gap; and recommending REASSIGN_TO_AGENT without verifying that the target agent actually has the required capability. Test this prompt with a golden dataset of failure logs that covers each failure pattern category, and measure whether the recommended action matches the expected resolution. If your system allows automatic reassignment or task disabling, add a hard gate that requires human approval before executing any destructive action, regardless of the model's output.
Prompt Variables
Inputs the prompt needs to work reliably. Populate these from your agent execution logs and orchestration metadata.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[AGENT_ID] | Identifies the failing agent instance for traceability and log correlation. | agent-7b3f2a | Must match a valid agent identifier in the orchestration log. Parse check: non-empty string matching agent ID pattern. |
[TASK_DEFINITION] | The original task assigned to the agent, including its success criteria. | Extract invoice totals from batch_2025-03-15 and write to payments_db | Must be the exact task string from the orchestration record. Null not allowed. Schema check: string with minimum 10 characters. |
[FAILURE_HISTORY] | Structured log of each attempt, including timestamp, error type, and error message. | [{"attempt":1,"error":"ToolTimeout","message":"payments_db unreachable after 30s"},{"attempt":2,"error":"ToolTimeout","message":"payments_db unreachable after 30s"}] | Must be a valid JSON array with at least 2 entries. Each entry requires attempt number, error type, and message fields. Schema check: array length >= 2. |
[RETRY_COUNT] | Total number of failed attempts before escalation. | 3 | Must be an integer >= 2. Parse check: integer. If retry count is below configured threshold, escalation should not fire. |
[AGENT_CAPABILITY_BOUNDARY] | Documented limits of what this agent is authorized or designed to handle. | Read-only access to payments_db; cannot modify connection strings or restart services | Must be a non-empty string describing explicit boundaries. Null allowed if no boundary document exists, but escalation should flag this as a risk. |
[ORCHESTRATION_CONTEXT] | Broader workflow state including upstream dependencies, sibling agent status, and overall task deadline. | Workflow: monthly_close; Depends on: agent-ledger-export (completed); Deadline: 2025-03-16T00:00:00Z | Must include workflow identifier and at least one dependency status. Parse check: valid JSON or structured string. Null allowed if orchestrator does not provide context. |
[ESCALATION_POLICY] | The configured rules for when and how to escalate, including severity thresholds and target human roles. | Escalate after 3 failures of same error type; target: db-ops-team; severity: high | Must reference a valid policy identifier or inline rule set. Schema check: non-empty string. If policy is missing, escalation prompt must flag this and default to generic handoff. |
Implementation Harness Notes
How to wire the escalation prompt into an orchestration layer with validation, retry limits, and human review queues.
This prompt is designed to be invoked by an orchestrator or agent framework after a monitored agent has exceeded a configurable failure threshold for the same task. The harness should track attempts per task ID, classify failure types (tool error, parse error, timeout, policy refusal), and only trigger this escalation prompt when the retry budget is exhausted. Do not call this prompt on the first failure; it is a circuit breaker, not a retry mechanism. The orchestrator must pass the full failure log, the original task definition, and the agent's role specification into the [FAILURE_LOG], [TASK_CONTEXT], and [AGENT_SPEC] placeholders respectively.
Before sending the prompt, the harness must validate that the failure log contains at least two distinct attempts with the same task ID and that the failure types are not transient infrastructure errors (e.g., a 503 from an upstream API that should be handled by exponential backoff at the transport layer). The model choice should favor reasoning-capable models (such as Claude 3.5 Sonnet or GPT-4o) because the prompt requires pattern recognition across failure traces and root cause analysis. Set temperature to 0.1 or lower to reduce variance in the escalation recommendation. The output must be parsed into a typed object matching the [OUTPUT_SCHEMA] defined in the prompt, with fields for root_cause_category, recommended_action (one of reassign, redesign, escalate_permanently), and human_summary. If the model returns an invalid action or the JSON is malformed, the harness should log the raw output and default to escalate_permanently as a safe fallback, then notify the on-call channel.
For high-risk domains such as healthcare, finance, or safety-critical operations, the harness must route the generated escalation to a human review queue regardless of the model's recommendation. The human_summary field should be rendered in a ticket or incident management system (e.g., Jira, ServiceNow, PagerDuty) with a link to the full trace. Implement a feedback loop: when a human reviewer resolves the escalation, capture their decision and the actual root cause. This data becomes the evaluation set for measuring whether the escalation prompt's root cause classification and recommended action align with human judgment over time. Track the false-positive rate of escalations (cases where the agent could have recovered with a different retry strategy) and the miss rate (cases where the agent was not escalated but should have been). Use these metrics to tune the failure threshold and the prompt's instructions, not to automate the decision away from human review in high-stakes workflows.
Expected Output Contract
Validate the escalation JSON payload produced by the prompt. Each row defines a required field, its type, and the validation rule to apply before the escalation is routed to a human reviewer or downstream system.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
escalation_id | string (UUID v4) | Must parse as a valid UUID v4; reject if null or empty | |
agent_id | string | Must match the pattern [AGENT_ID_PATTERN]; reject if agent is not registered in the orchestration layer | |
task_signature | string | Must be a non-empty string that uniquely identifies the task; validate against the task registry if available | |
failure_attempts | integer | Must be an integer >= [ESCALATION_THRESHOLD]; reject if less than the configured retry limit | |
failure_patterns | array of objects | Each object must contain 'attempt' (integer), 'error_type' (string from [ERROR_TAXONOMY]), and 'timestamp' (ISO 8601); array must not be empty | |
root_cause_analysis | object | Must contain 'likely_cause' (string, non-empty), 'confidence' (float 0.0-1.0), and 'evidence' (array of strings); reject if confidence is below [MIN_RCA_CONFIDENCE] | |
recommended_action | string | Must be one of the allowed enum values: 'reassign', 'redesign', 'escalate_permanently', 'retry_with_fix'; reject unknown values | |
handoff_payload | object | Must contain 'summary' (string, max 500 chars) and 'full_log' (string); summary must not be empty; full_log must include all attempt traces |
Common Failure Modes
Escalation prompts fail in predictable ways when repeated agent failures are aggregated. These cards cover the most common failure modes and how to guard against them before the escalation reaches a human reviewer.
Vague Root Cause Summaries
What to watch: The escalation prompt produces generic root cause labels like 'agent error' or 'system failure' instead of actionable diagnostics. This happens when the prompt lacks a taxonomy of failure categories or when the agent's own error logs are too sparse. Guardrail: Require the prompt to map each failure to a structured failure taxonomy (e.g., tool timeout, schema mismatch, permission denied, ambiguous input) and cite the specific error message or log line that supports the classification.
Missing Failure Pattern Correlation
What to watch: The prompt lists individual failures chronologically but fails to identify that three different-looking errors share the same underlying cause (e.g., a deprecated API version causing cascading tool failures). Guardrail: Add an explicit instruction to group failures by suspected root cause before generating the escalation, and require the output to include a 'correlated failures' section with evidence linking the incidents.
Premature Permanent Escalation
What to watch: The prompt recommends permanently reassigning the task to a human after a small number of retries, even when a configuration change or tool fix would resolve the issue. This creates unnecessary human toil. Guardrail: Include a decision tree in the prompt that distinguishes between transient failures (retry with backoff), configurable failures (flag for ops), capability gaps (reassign to a different agent), and true dead ends (permanent human escalation). Require justification for the chosen path.
Context Truncation in Long Failure Histories
What to watch: When an agent fails 20+ times, the full failure history exceeds the escalation prompt's context window. The model receives only the most recent failures and misses the initial trigger event that explains the whole cascade. Guardrail: Summarize older failures into a compressed timeline with key events and error signatures before passing them to the escalation prompt. Preserve the first failure and any state-change events in full detail.
Recommendation Without Feasibility Check
What to watch: The prompt recommends a fix (e.g., 'update the API schema') without checking whether the human reviewer has the authority, access, or context to execute that fix. The escalation becomes a dead end. Guardrail: Require each recommendation to include an 'actionable by' field specifying the role or team that can execute it, and flag recommendations that fall outside the escalation recipient's known scope.
Failure Count Thresholds Without Rate Context
What to watch: The escalation triggers on a raw failure count (e.g., '3 failures') without considering the failure rate or time window. Three failures over six months is a different signal than three failures in one minute. Guardrail: Include failure rate, time window, and burst detection in the escalation prompt's input schema. Instruct the model to weigh recency and density when assessing severity, not just absolute count.
Evaluation Rubric
Run these checks on a golden dataset of known failure patterns to validate the escalation prompt before production deployment. Each criterion targets a specific failure mode common in repeated agent failure scenarios.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Root Cause Identification | Output identifies a specific, plausible root cause from the failure log, not a generic category like 'agent error'. | Output lists symptoms without a causal statement or defaults to 'unknown error'. | Provide failure logs with a known injected root cause (e.g., tool timeout). Check if the output names the cause. |
Failure Pattern Aggregation | Output groups repeated failures by type and includes counts or timestamps, not just a raw log dump. | Output repeats individual failure messages without aggregation or misses a recurring pattern present in the log. | Feed a log with 5 identical tool errors and 2 distinct parsing errors. Verify the output identifies both groups. |
Reassignment Recommendation | Output recommends a specific target (agent, human queue, or fallback) with a clear justification tied to the root cause. | Recommendation is 'escalate to human' without specifying why the agent cannot recover or what skill is missing. | Test with a capability gap failure. Check that the recommendation names the missing capability. |
Redesign Recommendation | If applicable, output suggests a concrete change to the agent's instructions, tool, or timeout. If not applicable, explicitly states no redesign is needed. | Output suggests 'improve the agent' without a specific, actionable change or omits the redesign option entirely. | Test with a timeout failure. Check for a specific suggestion like 'increase tool timeout from 30s to 60s'. |
Permanent Escalation Criteria | Output states clear conditions under which this task should be permanently reassigned, not just retried. | Output only recommends a retry or temporary reassignment without defining a permanent breakpoint. | Provide a log where the agent has failed 10 times across 3 remediation attempts. Check for a 'stop retrying' condition. |
Evidence Traceability | Every cited failure references a specific log entry ID, timestamp, or attempt number present in the input. | Output makes a claim about a failure without pointing to a specific instance in the provided log. | Parse the output and verify each failure claim maps to an input log entry. Flag orphan claims. |
Confidence and Uncertainty | Output includes a confidence qualifier for the root cause assessment and explicitly notes any missing information. | Output presents the root cause as definitive when the log evidence is ambiguous or incomplete. | Provide a log with two equally plausible causes. Check that the output acknowledges the ambiguity. |
Output Schema Validity | Output parses cleanly against the defined [OUTPUT_SCHEMA] with all required fields present and correctly typed. | Output is missing a required field, contains a malformed enum value, or has a type mismatch. | Validate the raw output against the JSON Schema. Flag any schema violations. |
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
Use the base prompt with a simple JSON schema and a single failure-count threshold. Focus on getting the escalation structure right before adding production complexity.
code[AGENT_ID] has failed [TASK_ID] [FAILURE_COUNT] times. Last error: [LAST_ERROR] Produce an escalation with: - failure_summary - likely_root_cause - recommended_action (reassign|redesign|escalate_permanently)
Watch for
- Missing schema checks causing downstream parse failures
- Overly broad root cause guesses without evidence
- No distinction between transient and persistent failures

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