Inferensys

Prompt

Graceful Degradation When Primary Tool Unavailable Prompt Template

A practical prompt playbook for using the Graceful Degradation When Primary Tool Unavailable Prompt Template in production AI workflows.
Developer doing prompt engineering on laptop, prompt variations visible on screen, casual coding session.
PROMPT PLAYBOOK

When to Use This Prompt

Identifies the specific production scenarios where a structured degradation plan is the correct recovery strategy, and clarifies when simpler retry logic or direct error propagation is more appropriate.

This prompt is designed for product reliability teams, SREs, and AI infrastructure engineers who need an AI system to self-heal when a primary tool call fails due to an outage, network partition, or dependency failure. The core job-to-be-done is not a simple retry, but a deliberate orchestration of a degraded operational state. Instead of returning a raw error to the user, the model generates a structured degradation plan that selects an alternative tool, prepares a static fallback response, or crafts a transparent user-facing message. Use this prompt when your application's tool-calling layer detects that a primary tool is unreachable and you need the model to decide the next best action based on available fallback options, feature flags, and operational constraints.

The ideal user is an engineer embedding this prompt into a recovery harness. The required context includes a list of available fallback tools with their capabilities and costs, the current feature flag state, the original user intent, and the specific failure mode (e.g., timeout, 503, connection refused). The prompt is most effective when the system has multiple degraded paths to choose from, such as a cached result, a less-precise alternative tool, or a static help article. It should not be used for simple retry logic, single-tool timeout recovery, or cases where the only acceptable outcome is a successful call to the primary tool. For those, use the dedicated Tool Call Timeout Recovery Prompt Template or API Rejection Retry with Backoff Prompt Template.

A concrete implementation example is an e-commerce support copilot whose primary order-lookup API is returning 503 errors. The harness detects the failure and invokes this prompt with the context of a secondary, read-only reporting database that is 15 minutes stale, a static 'check order status' help page, and a feature flag enabling degraded mode. The model's degradation plan would select the reporting database for a lookup, prepend a staleness warning to the user response, and log the event for the monitoring system. This is a deliberate shift to a functional but degraded state, not a blind retry loop.

Avoid using this prompt when the failure is transient and a simple retry with backoff is the correct engineering response. It is also inappropriate when no alternative tool or fallback path exists, as the model will be forced to generate a plan it cannot execute, leading to a confusing user experience. In high-risk domains such as healthcare or finance, the degradation plan must always include a human review gate before execution, and the prompt's output should be treated as a recommendation, not an autonomous action. The next step after reading this section is to review the prompt template and prepare your tool capability registry and feature flag schema.

PRACTICAL GUARDRAILS

Use Case Fit

This prompt is designed for production reliability systems that must self-heal when a primary tool is unavailable. It is not a generic fallback message generator. Use it when the cost of a wrong degradation decision is high and the system needs an auditable plan.

01

Good Fit: Automated SRE Runbooks

Use when: a primary API, database, or internal service is unreachable and the system must autonomously select a fallback tool, static response, or user communication template. Guardrail: Bind the prompt to a feature-flag service and a live SLA context so the degradation plan respects current operational constraints.

02

Bad Fit: Undefined Fallback Inventory

Avoid when: the system has no pre-registered alternative tools, cached data sources, or static response templates. Guardrail: The prompt requires a structured inventory of available fallbacks. Without it, the model will hallucinate non-existent tools, creating a secondary failure mode.

03

Required Input: Live Operational Context

What to watch: The prompt cannot make safe decisions without knowing current feature flags, rate limits, and circuit breaker states. Guardrail: Inject a real-time operational context block into the prompt before execution. Stale context leads to degraded plans that violate active system constraints.

04

Operational Risk: Silent Degradation Drift

What to watch: A degradation plan that works during the incident may become invalid seconds later if a fallback tool also fails or a circuit breaker opens. Guardrail: Pair this prompt with a post-execution validation step that re-checks the availability of every tool in the proposed plan before execution.

05

Operational Risk: User-Facing Leakage

What to watch: The model may include internal endpoint names, stack traces, or vendor-specific error codes in the user communication template. Guardrail: Apply a strict output schema that separates the internal degradation plan from the user-facing message, and validate the user message with a PII/secret scanner before delivery.

06

Good Fit: Audit-Ready Recovery

Use when: you need a structured, explainable record of why a specific fallback was chosen. Guardrail: Instruct the prompt to output a decision rationale block alongside the plan. This block should cite the specific tool unavailability signal, the ranked fallback options, and the trade-off reasoning for the final selection.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable system prompt that instructs the model to produce a structured degradation plan when a primary tool is unavailable.

This template is designed to be placed in your system prompt or invoked as a dedicated recovery step when your application detects that a primary tool is unreachable, timing out, or returning a fatal error. It forces the model to reason about available alternatives, operational constraints, and user communication before emitting a structured plan. The output is not a conversational reply but a machine-readable degradation decision that your application harness can execute.

text
You are a reliability engineer responsible for maintaining service when a primary tool is unavailable.

## CONTEXT
- Primary tool that failed: [PRIMARY_TOOL_NAME]
- Failure mode: [FAILURE_MODE] (e.g., timeout, 503, connection refused, circuit breaker open)
- User intent that triggered the tool call: [USER_INTENT]
- Available alternative tools with their capabilities, costs, and latencies:
[AVAILABLE_TOOLS]
- Current operational constraints:
  - Latency budget remaining: [LATENCY_BUDGET_MS]ms
  - Cost budget remaining: [COST_BUDGET]
  - Feature flags active: [FEATURE_FLAGS]
  - User permission scope: [USER_PERMISSIONS]
- Retry state: [RETRY_STATE] (e.g., first failure, retries exhausted, circuit breaker open)
- Monitoring alert status: [ALERT_STATUS]

## TASK
Produce a degradation plan as a JSON object with the following schema:
{
  "decision": "fallback_tool" | "static_response" | "user_clarification" | "escalate_to_human" | "fail_gracefully",
  "selected_fallback_tool": string | null,
  "fallback_tool_arguments": object | null,
  "static_response_text": string | null,
  "user_facing_message": string,
  "confidence": 0.0-1.0,
  "reasoning": string,
  "monitoring_alert_update": string | null,
  "requires_human_approval": boolean
}

## CONSTRAINTS
1. If a fallback tool is selected, it must be in the available tools list and must not exceed the latency or cost budgets.
2. If no fallback tool meets constraints, prefer static_response or user_clarification over guessing.
3. The user_facing_message must be transparent about degradation without exposing internal failure details, error codes, or tool names.
4. If confidence is below 0.7, set requires_human_approval to true.
5. If the circuit breaker is open, do not select any tool that depends on the same downstream service.
6. If feature flags disable a fallback tool, treat it as unavailable.
7. If the user lacks permission for a fallback tool, do not select it.

## EXAMPLES
[FEW_SHOT_EXAMPLES]

## OUTPUT
Return only the JSON object. No markdown fences, no commentary.

Adapt this template by replacing the square-bracket placeholders with runtime values from your application context. The [AVAILABLE_TOOLS] placeholder should be populated with a structured list of tool names, descriptions, typical latencies, and costs so the model can make informed trade-offs. The [FEW_SHOT_EXAMPLES] placeholder is critical for production reliability: include at least two examples showing correct degradation decisions for common failure modes in your system. Before deploying, validate that the output JSON matches the schema exactly and that your harness can parse and act on each decision value. For high-risk domains, route any plan with requires_human_approval: true to a review queue before execution.

IMPLEMENTATION TABLE

Prompt Variables

Inputs the prompt needs to work reliably. Provide these from your application's operational context.

PlaceholderPurposeExampleValidation Notes

[PRIMARY_TOOL_NAME]

Identifies the tool that is currently unavailable

customer_lookup_api_v2

Must match a registered tool name in the tool registry. Check against active tool manifest.

[PRIMARY_TOOL_FAILURE_MODE]

Describes how the primary tool failed

timeout_30s

Must be one of: timeout, 5xx, 4xx, connection_refused, circuit_open, rate_limited. Validate against error classifier output.

[AVAILABLE_TOOL_REGISTRY]

List of alternative tools with their capabilities, costs, and latency profiles

["cached_customer_lookup", "static_fallback_db", "manual_escalation_queue"]

Must be a valid JSON array of tool objects. Each tool must have name, capability_score, cost_estimate, and avg_latency_ms fields.

[FEATURE_FLAG_STATE]

Current feature flag configuration for degradation paths

{"enable_cached_fallback": true, "enable_static_response": false}

Must be a valid JSON object. Parse and confirm all referenced flags exist in the feature flag system.

[USER_CONTEXT]

Information about the current user's permissions, tier, and session state

{"tier": "enterprise", "permissions": ["read", "export"]}

Must include tier and permissions array. Null allowed for unauthenticated users. Validate tier against known values.

[OPERATIONAL_SLA]

Service level objectives that constrain degradation choices

{"max_latency_ms": 2000, "min_availability": 0.999}

Must include max_latency_ms and min_availability. Parse as numbers. Reject if max_latency_ms < 0.

[MONITORING_ALERT_CONTEXT]

Current alert state and recent incident context

{"active_alerts": ["latency_p50_high"], "recent_incidents": 2}

Must be a valid JSON object. active_alerts must be an array. Null allowed if no monitoring system is connected.

[PREVIOUS_DEGRADATION_DECISIONS]

History of recent degradation actions to avoid flip-flopping

[{"timestamp": "2024-01-15T10:00:00Z", "action": "cached_fallback"}]

Must be a valid JSON array. Each entry must have timestamp and action. Validate timestamps are ISO 8601 and within the lookback window.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the graceful degradation prompt into a production application with validation, retries, feature flags, and monitoring.

This prompt is designed to be invoked by an orchestration layer—not directly by an end user. When a primary tool call fails, times out, or returns an unrecoverable error, your application should catch the failure, enrich the context with the original intent, available fallback tools, and operational constraints, then call this prompt to produce a structured degradation plan. The prompt's output is a machine-readable plan that your harness parses and executes, not a user-facing message. Treat the degradation plan as a decision document that your system acts on: select the recommended fallback tool, serve a static response, or trigger a user communication template.

The implementation harness requires several pre-built components. First, maintain a tool registry that maps each primary tool to its fallback alternatives, including their cost profiles, latency characteristics, and capability gaps. Second, integrate a feature-flag service so the prompt can check whether fallback tools are currently enabled for the requesting tenant. Third, build a monitoring alert integration that fires when degradation plans are executed, capturing the failure reason, selected fallback, and SLA impact. Before executing the plan, validate that the selected fallback tool is actually available and that any static response templates referenced in the plan exist in your content store. If the prompt recommends a fallback that is also unavailable, re-invoke the prompt with the updated constraint set rather than silently failing.

Wire the prompt into a degradation decision loop with clear termination conditions. After receiving the structured degradation plan, your harness should: (1) validate the plan against the current tool registry and feature flags, (2) execute the selected fallback action, (3) log the full decision chain including the original failure, the prompt's reasoning, and the executed fallback, and (4) update your circuit breaker state if the fallback also fails. Set a maximum of two degradation attempts before escalating to a human operator via your incident management system. Avoid calling this prompt in a tight retry loop—degradation decisions should be made once per failure event, with the result cached for the duration of the outage window. For high-risk write operations, require explicit human approval before executing any fallback that mutates state, even if the prompt's confidence score is high.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, format, and validation rules for the model's JSON response when generating a degradation plan after a primary tool is unavailable.

Field or ElementType or FormatRequiredValidation Rule

degradation_plan_id

string (UUID v4)

Must parse as a valid UUID v4. Reject on format mismatch.

primary_tool_failure

object

Must contain tool_name (string), error_code (string), and failure_timestamp (ISO 8601). All three sub-fields required.

selected_fallback_tool

string or null

Must match an entry in the [AVAILABLE_TOOLS] list or be null. If null, fallback_reason must be 'no_alternative_available'.

fallback_arguments

object or null

If selected_fallback_tool is not null, must conform to the tool's parameter schema. If null, validate that selected_fallback_tool is also null.

static_response

object or null

If present, must contain message (string) and template_id (string). Required when selected_fallback_tool is null. Validate template_id against [STATIC_RESPONSE_TEMPLATES].

feature_flag_checks

array of objects

Each object must have flag_name (string), current_state (boolean), and degradation_impact (string). Array must not be empty.

user_communication

object

Must contain message (string) and severity (enum: 'transparent', 'deferred', 'blocking'). Validate severity against the enum. message must not expose internal tool names or error codes.

monitoring_alert_payload

object

Must contain alert_severity (enum: 'P1', 'P2', 'P3'), alert_summary (string), and alert_labels (object). All sub-fields required. Validate alert_severity against the enum.

PRACTICAL GUARDRAILS

Common Failure Modes

When the primary tool is unavailable, the degradation plan itself can fail. These are the most common production failure modes and how to guard against them.

01

Fallback Tool Also Unavailable

What to watch: The degradation plan selects a fallback tool, but that tool is also down, rate-limited, or unauthorized. Cascading failures produce a confusing error trace. Guardrail: Implement a fallback chain with a terminal static response. Test the full chain, including the last resort, in staging.

02

Stale Feature Flag Causes Wrong Path

What to watch: The model reads a cached or outdated feature flag and selects a degradation path that is no longer valid, such as a deprecated fallback endpoint. Guardrail: Include the feature flag state directly in the prompt context at inference time. Never rely on training-data knowledge of flags.

03

User-Facing Message Exposes Internals

What to watch: The degradation prompt generates a user message that leaks internal tool names, error codes, or infrastructure details, creating a security and trust issue. Guardrail: Add a strict output constraint that user-facing text must never include tool names, endpoints, or raw error messages. Validate with a regex post-processor.

04

Degradation Plan Ignores SLA Context

What to watch: The model selects a high-latency fallback tool for a request that requires a sub-second response, violating the user-facing SLA. Guardrail: Include latency budgets and SLA tier in the prompt context. Instruct the model to prefer a static response over a slow fallback when the budget is tight.

05

Silent Degradation Without Monitoring Alert

What to watch: The system degrades gracefully for the user, but no alert is fired. The operations team remains unaware of the primary tool outage for hours. Guardrail: The degradation prompt must output a structured alert_triggered: true field alongside the user message. An application-level rule fires the monitoring event.

06

Retry Loop Masquerading as Degradation

What to watch: The prompt instructs a retry on the primary tool before degrading, but the retry logic is unbounded, causing a 30-second hang before the fallback message appears. Guardrail: Set an explicit maximum retry budget (e.g., 1 retry, 200ms total) in the prompt constraints. Enforce a hard deadline in the application layer.

IMPLEMENTATION TABLE

Evaluation Rubric

Run these checks against a golden dataset of failure scenarios to validate the degradation plan before production deployment.

CriterionPass StandardFailure SignalTest Method

Primary tool unavailable triggers degradation plan

Plan activates within 1 turn when primary tool returns 503, timeout, or connection refused

Model retries primary tool indefinitely or returns raw error to user

Inject simulated 503 response; verify fallback tool selection or static response is returned

Fallback tool selection respects capability ranking

Selected fallback tool is the highest-ranked available alternative from [FALLBACK_CHAIN] with lower cost/latency than escalation

Model selects a fallback tool that is also unavailable or violates [CONSTRAINTS]

Provide ordered fallback chain with 2 of 3 tools marked unavailable; verify selection of the single available tool

Static degradation response matches [STATIC_FALLBACK_TEMPLATE]

Output contains all required fields from template: explanation, alternative action, and estimated resolution time

Output omits user-facing explanation, exposes internal error codes, or makes false promises about resolution

Compare output against [STATIC_FALLBACK_TEMPLATE] schema; check for presence of all required fields and absence of internal error strings

Feature flag awareness gates degradation path

When [FEATURE_FLAG] is false, model returns standard error without degradation; when true, degradation plan activates

Model applies degradation regardless of flag state or ignores flag entirely

Run same failure scenario with flag set to true and false; verify behavioral difference matches expected gating

User communication does not expose internal failure details

User-facing message contains no stack traces, endpoint URLs, internal service names, or raw error codes

Output includes 'Error 500 from inventory-service', 'Connection refused to 10.0.1.42', or similar internal details

Scan output with regex patterns for IPs, internal hostnames, HTTP status codes, and stack trace signatures; all must be absent

Monitoring alert payload is generated when degradation activates

Output includes structured [ALERT_PAYLOAD] with severity, failure type, affected tool, and timestamp

Alert payload is missing, malformed, or contains severity=critical for non-critical degradation

Validate [ALERT_PAYLOAD] against alert schema; verify severity field matches [DEGRADATION_SEVERITY] mapping

Degradation plan does not hallucinate unavailable capabilities

Fallback tool or static response only references capabilities present in [AVAILABLE_CAPABILITIES] list

Output promises features, data, or actions not present in any available fallback tool

Extract all capability claims from output; cross-reference against [AVAILABLE_CAPABILITIES]; flag any unmatched claims

Confidence threshold gates automatic vs. human-review degradation

When confidence in fallback quality is below [CONFIDENCE_THRESHOLD], output routes to [HUMAN_REVIEW_QUEUE] instead of auto-responding

Model auto-responds with low-confidence fallback or escalates when confidence is above threshold

Set [CONFIDENCE_THRESHOLD] to 0.9; inject scenario where best fallback has 0.6 confidence; verify human escalation trigger fires

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a hardcoded fallback chain of 2-3 tools. Use a simple JSON output schema with degradation_plan, selected_fallback, and user_message fields. Skip feature-flag checks and monitoring integration. Test with simulated tool unavailability by returning 503 from your tool harness.

code
You are a degradation planner. The primary tool [PRIMARY_TOOL] is unavailable.
Available alternatives: [ALTERNATIVE_TOOLS].
User request: [USER_REQUEST].
Return a JSON degradation plan with selected fallback and user-facing message.

Watch for

  • Model selecting a fallback tool that doesn't exist in the list
  • User messages that expose internal failure details
  • No distinction between transient and permanent unavailability
Prasad Kumkar

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.