This prompt is designed for SRE teams and platform engineers who operate multi-agent pipelines where a primary agent can fail due to tool errors, timeouts, capability gaps, or model unavailability. Instead of a hard failure, the system must select the best fallback path from a registry of alternative agents, static responses, or human queues. Use this prompt when you need a ranked, reasoned selection of fallback options that considers capability match, degradation impact, latency budget, and cost. It is not a retry prompt or a simple error handler; it assumes the primary agent has already exhausted its recovery options and the orchestrator must now route the task elsewhere.
Prompt
Fallback Path Selection Prompt for Agent Failures

When to Use This Prompt
Understand the job-to-be-done, the ideal user, and the operational boundaries for the fallback path selection prompt.
The ideal user is an orchestration engineer or platform operator who maintains a fallback registry—a structured catalog of available agents, their capabilities, cost profiles, and average latencies. The prompt requires this registry as input, along with the failed agent's context, the original task, and any error diagnostics. It is not suitable for real-time, sub-100ms decision loops where a hardcoded static fallback is more appropriate. Do not use this prompt when the primary agent's failure mode is unknown or when the system lacks a defined fallback registry; in those cases, the output will be speculative and unreliable.
Before wiring this prompt into production, ensure you have instrumented the primary agent's failure signal with enough detail: the error type, the tool that failed, the remaining latency budget, and the task's risk classification. The prompt's value comes from its ability to weigh trade-offs—trading accuracy for speed, or cost for capability—but it can only do that if the input context is complete. Proceed to the prompt template section to see the exact input schema and adapt it to your agent topology.
Use Case Fit
Where the Fallback Path Selection Prompt delivers value and where it introduces risk. Use these cards to decide if this prompt fits your multi-agent reliability architecture.
Good Fit: Heterogeneous Agent Fleets
Use when: you operate multiple specialized agents with distinct capability profiles and need automated fallback routing when a primary agent fails. Guardrail: maintain an up-to-date capability registry for each agent so the prompt can match failure signatures to fallback candidates accurately.
Bad Fit: Single-Agent Deployments
Avoid when: your system has only one agent with no alternative execution paths. The prompt generates fallback rankings that cannot be actioned. Guardrail: implement retry logic or human escalation instead of multi-agent fallback selection when no secondary agents exist.
Required Inputs
Must provide: primary agent failure classification, current task context, available agent capability registry, and degradation tolerance thresholds. Guardrail: validate that the capability registry is fresh before each invocation—stale agent profiles produce incorrect fallback rankings.
Operational Risk: Cascading Fallback Failures
What to watch: the prompt may select a fallback agent that also fails, triggering a chain of degradations without resolution. Guardrail: implement a circuit breaker that limits fallback depth and escalates to human review after N consecutive agent failures.
Latency Sensitivity
What to watch: fallback selection adds decision latency to already-failing requests, which can violate SLA budgets for time-sensitive workflows. Guardrail: set a hard timeout on the fallback selection step and pre-compute static fallback paths for known failure modes to bypass runtime ranking.
Capability Match Drift
What to watch: agent capabilities evolve over time, and the prompt may recommend fallback agents whose actual capabilities no longer match the registry. Guardrail: pair this prompt with a capability gap detection check that validates the selected fallback agent can actually handle the task before routing.
Copy-Ready Prompt Template
A copy-ready prompt template for selecting the optimal fallback path when an agent fails, including ranked candidates, capability match scores, and degradation impact.
This prompt is designed to be placed in your orchestrator's error-handling step, immediately after an agent returns a failure status, timeout, or invalid output. Its job is to reason over the available fallback agents, their capabilities, current system state, and the original task to produce a ranked, actionable routing decision. Do not use this prompt for initial task routing; it assumes a failure has already occurred and focuses strictly on graceful degradation.
textYou are a fallback path selector for a multi-agent system. An agent has failed to complete its assigned task. Your job is to select the best fallback agent or path to minimize disruption. ## FAILED AGENT - Agent ID: [FAILED_AGENT_ID] - Agent Role: [FAILED_AGENT_ROLE] - Failure Reason: [FAILURE_REASON] - Failure Type: [FAILURE_TYPE] (e.g., timeout, tool_error, invalid_output, capability_gap, policy_block) ## ORIGINAL TASK - Task ID: [TASK_ID] - User Intent Summary: [USER_INTENT_SUMMARY] - Required Capabilities: [REQUIRED_CAPABILITIES] - Task Priority: [TASK_PRIORITY] (e.g., critical, high, medium, low) - SLA Deadline (ms): [SLA_DEADLINE_MS] - Remaining SLA Budget (ms): [REMAINING_SLA_BUDGET_MS] ## AVAILABLE FALLBACK AGENTS [FALLBACK_AGENTS_LIST] <!-- Each entry: agent_id, role, capabilities (list), current_load (0.0-1.0), avg_latency_ms, cost_per_call_usd, reliability_score (0.0-1.0) --> ## CONSTRAINTS - Do not select the failed agent. - Prefer agents whose capabilities cover the required capabilities. - If no agent covers all required capabilities, select the agent with the highest partial coverage and note the gap. - If remaining SLA budget is below any agent's avg_latency_ms, recommend a fast-degradation path (e.g., cached response, static fallback, human queue with urgency flag). - If task priority is critical, prefer reliability over cost. - If failure type is policy_block, do not route to another automated agent; escalate to human review. ## OUTPUT SCHEMA Return a JSON object with this exact structure: { "fallback_decision": { "selected_agent_id": string | null, "selected_agent_role": string | null, "ranked_candidates": [ { "agent_id": string, "role": string, "capability_match_score": number (0.0-1.0), "missing_capabilities": [string], "degradation_impact": "none" | "minor" | "moderate" | "severe", "estimated_latency_ms": number, "estimated_cost_usd": number, "rationale": string } ], "escalation_required": boolean, "escalation_target": "human_review" | "incident_queue" | null, "circuit_breaker_triggered": boolean, "decision_rationale_summary": string } } ## RULES - Rank candidates by capability_match_score descending, then by degradation_impact ascending, then by reliability_score descending. - If the top candidate has a capability_match_score below [MIN_CAPABILITY_THRESHOLD], set escalation_required to true. - If the same task has failed more than [MAX_CONSECUTIVE_FAILURES] times across any agents, set circuit_breaker_triggered to true and escalate. - Provide specific, actionable rationale for each candidate.
Adaptation notes: Replace every square-bracket placeholder with runtime values from your orchestrator's state. The [FALLBACK_AGENTS_LIST] should be populated from your agent registry, filtered to exclude the failed agent and any agents currently in a circuit-broken state. Wire [MAX_CONSECUTIVE_FAILURES] and [MIN_CAPABILITY_THRESHOLD] to your operational config. For high-risk domains, add a [REQUIRES_HUMAN_APPROVAL] boolean field to the output schema and route decisions through a review queue before execution. Validate the JSON output against the schema before acting on the routing decision; if parsing fails, default to the human escalation path and log the raw response for debugging.
Prompt Variables
Runtime inputs required by the Fallback Path Selection Prompt. Validate these before calling the model to prevent hallucinated fallback paths and ensure the agent has the context needed to rank alternatives correctly.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[FAILED_AGENT_ROLE] | Identifies the agent that failed so the prompt can reason about capability gaps | data_extraction_agent | Must match a registered agent ID in the agent registry. Reject null or unknown roles before prompt assembly. |
[FAILURE_REASON] | Describes why the agent failed, enabling capability-gap matching against fallback candidates | Tool timeout after 3 retries on PDF parsing endpoint | Must be non-empty string. If null, set to 'Unknown failure' and flag for human review. Truncate at 2000 characters. |
[ORIGINAL_TASK] | The task the failed agent was attempting, used to score fallback path relevance | Extract all financial tables from Q3 10-Q filing and normalize to CSV | Must be non-empty. Validate that task intent is preserved. If task was modified during execution, use the original requested task. |
[AVAILABLE_FALLBACK_PATHS] | List of candidate agents, tools, or human queues that could take over | ["manual_review_queue", "legacy_ocr_agent", "gpt4_vision_agent"] | Must be a non-empty array. Each entry must resolve to a reachable endpoint or queue. Remove paths that are themselves in a failed or degraded state. |
[CURRENT_STATE_PAYLOAD] | Partial results, intermediate artifacts, and context the fallback path can reuse | {"pages_processed": 12, "tables_extracted": 3, "last_successful_page": 11} | Must be valid JSON. Validate schema against expected state contract. Null allowed if no partial results exist. Strip PII before passing. |
[DEGRADATION_CONSTRAINTS] | Latency budget, cost ceiling, and accuracy requirements that constrain fallback selection | {"max_latency_ms": 30000, "max_cost_cents": 50, "min_accuracy": 0.85} | Must be valid JSON with numeric fields. If null, apply default constraints from system config. Reject negative values. |
[PREVIOUS_ESCALATION_COUNT] | Number of times this task has already been escalated, used to prevent infinite loops | 2 | Must be an integer >= 0. If count exceeds circuit breaker threshold (default 3), force human escalation and skip model call. |
[AGENT_CAPABILITY_MATRIX] | Known capabilities of each fallback path, used for match scoring | {"legacy_ocr_agent": ["pdf_parsing", "table_extraction"], "manual_review_queue": ["complex_layouts"]} | Must be valid JSON mapping agent IDs to capability arrays. Validate that every fallback path has an entry. Reject if matrix is empty. |
Implementation Harness Notes
How to wire the Fallback Path Selection Prompt into an orchestrator as a late-stage recovery step with validation, logging, and observability hooks.
This prompt is not a standalone one-shot. It is designed to run inside an agent orchestrator's fallback selection step, triggered only after the primary agent has exhausted its retry budget. The orchestrator should invoke this prompt with a structured context payload containing the original task, the primary agent's failure trace, and the available fallback agent registry. The prompt's output—a ranked list of fallback paths with capability match scores and degradation impact—is then consumed by the orchestrator to route the task to the next best agent or to a human queue.
To integrate this prompt, build a FallbackSelector module in your orchestrator with the following contract: Inputs include [ORIGINAL_TASK] (the user request and any partial results), [FAILURE_TRACE] (error codes, retry count, tool-call failures, timeout events), and [FALLBACK_REGISTRY] (a JSON array of available agents with their capability descriptions, cost profiles, and SLA windows). Output validation must check that the returned JSON contains a ranked_fallbacks array where each entry has agent_id, capability_match_score (0-1 float), degradation_impact (enum: low/medium/high/critical), and rationale (string). Reject and retry the prompt if the top-ranked agent is not present in the input registry or if scores fall outside the 0-1 range. Log every fallback selection event with a fallback_selection_id for traceability.
For production observability, instrument the harness with two key metrics: fallback success rate (did the selected fallback agent complete the task successfully?) and fallback latency (time from primary agent failure to fallback completion). Store these alongside the fallback_selection_id in your monitoring system. If the top-ranked fallback also fails, the orchestrator should re-invoke this prompt with the updated failure trace but exclude the already-failed agent from the registry. Set a hard limit of two fallback attempts before routing to a human review queue with the full failure history. Avoid running this prompt in hot paths where latency is critical—it is a recovery mechanism, not a real-time router.
Expected Output Contract
The orchestrator must validate the fallback path selection response against this contract before routing. Reject any response that fails these checks and trigger the retry or circuit-breaker path.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
fallback_ranking | Array of objects | Must contain 1-5 entries. Reject if empty or null. | |
fallback_ranking[].agent_id | String matching [AGENT_REGISTRY] | Must match an active agent ID in the registry. Reject unknown IDs. | |
fallback_ranking[].capability_match_score | Float 0.0-1.0 | Must be a number between 0 and 1 inclusive. Reject non-numeric or out-of-range values. | |
fallback_ranking[].rationale | String, max 300 chars | Must be non-empty and reference the failed agent's capability gap. Reject generic rationales. | |
fallback_ranking[].degradation_impact | Enum: none, minor, moderate, severe | Must be one of the four allowed values. Reject any other string. | |
fallback_ranking[].estimated_latency_ms | Integer or null | If provided, must be a positive integer. Null allowed when agent latency is unknown. | |
selection_confidence | Float 0.0-1.0 | Must be a number between 0 and 1. If below [CONFIDENCE_THRESHOLD], escalate to human review. | |
circuit_breaker_triggered | Boolean | Must be true or false. If true, the orchestrator must halt routing and enter cooldown state. |
Common Failure Modes
What breaks first when selecting fallback paths for agent failures and how to guard against it. Test these scenarios in your staging environment before production deployment.
Empty or Missing Fallback List
What to watch: The prompt receives an empty fallback agent list or the list is omitted entirely, causing the model to hallucinate agent names or return a confident but fabricated ranking. Guardrail: Validate that the [FALLBACK_AGENTS] input is non-empty before invoking the prompt. Return a hard error code if the list is missing, and log the failure for operator review.
Capability Score Inflation
What to watch: The model assigns uniformly high capability match scores (0.9+) to all candidates, making the ranking useless for differentiation. This often happens when agent descriptions are vague or overlapping. Guardrail: Require the prompt to output a score distribution summary. Flag responses where the standard deviation of scores is below 0.1 and request more granular agent capability descriptions.
Ignoring Degradation Impact
What to watch: The prompt selects a fallback agent based on capability match alone, ignoring that the fallback introduces unacceptable latency, cost, or user-experience degradation. Guardrail: Include a [DEGRADATION_THRESHOLD] parameter in the prompt template. Reject any fallback selection where the estimated degradation impact exceeds the threshold, and escalate to a human operator instead.
Stale Agent Registry Drift
What to watch: The fallback agent list is sourced from a stale registry. The prompt confidently routes to an agent that has been deprecated, renamed, or had its capabilities changed. Guardrail: Require a last_validated timestamp in the [FALLBACK_AGENTS] input. Reject the prompt if the registry data is older than the configured [MAX_REGISTRY_AGE] and force a registry refresh before ranking.
Circular Fallback Chains
What to watch: Agent A fails and falls back to Agent B, which fails and falls back to Agent A, creating an infinite loop that exhausts resources. Guardrail: Pass a [CALL_STACK] or visited-agent list into the prompt context. Instruct the model to exclude any agent already in the call stack from the fallback ranking. Add a circuit breaker that terminates after [MAX_FALLBACK_DEPTH] hops.
Rationale-Only Without Actionable Output
What to watch: The prompt produces a well-reasoned explanation of why each fallback was chosen but fails to return a machine-readable agent ID or endpoint, breaking the automated handoff. Guardrail: Enforce a strict [OUTPUT_SCHEMA] that requires selected_agent_id, endpoint, and handoff_payload fields. Validate the output against the schema before the orchestration layer consumes it.
Evaluation Rubric
Run these checks against a golden dataset of 20+ failure scenarios with known-good fallback selections. Each row validates a specific quality dimension of the fallback path selection output.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Fallback ranking order | Ranked list matches known-good ordering for all 20 scenarios | Top-ranked fallback differs from expected selection in >2 scenarios | Compare output ranking against golden dataset expected ordering; compute Kendall tau distance |
Capability match score calibration | Score difference between selected and rejected fallbacks is >=0.15 for clear-cut cases | Scores cluster within 0.05 for all candidates when capability gap is obvious | Measure score spread across candidates; flag scenarios where top-2 scores differ by <0.1 |
Rationale grounding | Every rationale sentence references a specific capability gap or failure mode from [AGENT_FAILURE_CONTEXT] | Rationale contains unsupported claims or hallucinated agent capabilities not in input | Parse rationale sentences; check each claim against [AGENT_FAILURE_CONTEXT] fields using substring or embedding match |
Degradation impact honesty | Degradation impact field is non-null and describes a concrete trade-off for every fallback | Degradation impact is null, empty, or uses vague language like 'some impact' | Assert degradation_impact is not null and contains >=1 specific capability or latency mention per fallback |
Latency estimate reasonableness | Estimated latency for each fallback is within 2x of known benchmark for that path | Latency estimate is 0, null, or exceeds 10x known benchmark without justification | Compare latency_estimate_ms against pre-recorded benchmark ranges per fallback type; flag outliers |
Fallback count appropriateness | Returns 2-5 fallback paths; does not return empty list or exhaustive catalog | Returns 0 fallbacks or >10 fallbacks with near-identical scores | Assert len(fallbacks) >= 2 and len(fallbacks) <= 5; flag if all scores within 0.05 range |
Escalation reason code validity | Reason code matches one of the predefined codes in [ESCALATION_REASON_CODES] | Reason code is novel, misspelled, or contradicts the failure description | Validate reason_code against allowed enum list; cross-check with failure_type in input context |
Output schema compliance | JSON output passes schema validation with all required fields present and correctly typed | Missing required field, wrong type, or extra fields that break downstream parsing | Validate output against [OUTPUT_SCHEMA] using JSON Schema validator; reject on any violation |
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 prompt and a simple JSON schema. Use a single model call with no retry logic. Hardcode a short list of fallback agents (e.g., ["human_operator", "retry_with_context"]). Skip capability match scoring—just rank by priority.
code[AGENT_ID]: [CURRENT_AGENT] [FAILURE_MODE]: [TIMEOUT | TOOL_ERROR | LOW_CONFIDENCE] [AVAILABLE_FALLBACKS]: ["agent_b", "human_review"]
Watch for
- Missing schema validation on the ranked list
- Overly broad instructions that produce prose instead of structured output
- No latency tracking, so you can't measure degradation impact

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