Inferensys

Prompt

Retry Policy and Backoff Design Prompt

A practical prompt playbook for using the Retry Policy and Backoff Design Prompt in production AI-assisted architecture review workflows.
Developer designing multi-agent workflow on laptop, architecture diagram on screen, casual home office setup with afternoon light.
PROMPT PLAYBOOK

When to Use This Prompt

Understand the job this prompt performs, the context it requires, and the situations where it should not be applied.

This prompt is designed for SREs and backend engineers who need to design or review a message retry strategy before it ships. It acts as a structured design review partner, producing a comprehensive analysis of a proposed or existing retry policy. The output covers critical dimensions such as the chosen backoff algorithm, maximum retry limits, jitter configuration, and integration with circuit breaker patterns. Use it during the design phase of a new service, when auditing an existing policy for resilience gaps, or as part of a formal pre-production resilience review.

To use this prompt effectively, you must provide concrete context. The prompt assumes you can supply the current or proposed policy configuration, including specific parameters like base intervals, max attempts, and jitter strategy. You also need to articulate the system's consistency requirements—specifically whether operations are idempotent—and describe the expected failure modes of downstream dependencies, such as timeouts, rate limiting, or transient network errors. Without this input, the review will be generic and may miss critical failure modes like thundering herd problems or poison message amplification.

Do not use this prompt for real-time incident response. It is a design-time tool, not a replacement for an on-call runbook. It is also fundamentally unsafe to use for systems where retries are inherently dangerous, such as non-idempotent payment capture endpoints or commands that trigger irreversible physical actuation. In these high-risk scenarios, a retry-first strategy can cause duplicate financial transactions or dangerous physical outcomes, and the correct design pattern is a human-in-the-loop reconciliation process, not an automated backoff algorithm. After the review, the next step is to codify the approved policy into your application's resilience library and validate it against the failure modes identified in the prompt's output.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Retry Policy and Backoff Design Prompt works, where it does not, and the operational risks to manage before putting the output into production.

01

Strong Fit: Greenfield Policy Design

Use when: you are designing a retry policy for a new service or event handler and need a structured review of backoff algorithms, jitter configuration, and max retry limits before writing code. Guardrail: treat the output as a design starting point, not a final configuration. Validate all recommended timeouts and limits against your actual infrastructure latency profiles.

02

Strong Fit: Pre-Production Resilience Review

Use when: conducting a resilience review of an existing retry implementation before a launch or major traffic increase. Guardrail: pair the prompt output with load-test results. The model can identify missing circuit breaker integration or thundering herd risks, but it cannot measure actual system behavior under load.

03

Poor Fit: Real-Time Incident Response

Avoid when: you are in an active incident and need immediate remediation steps. This prompt produces a design review, not a runbook command. Guardrail: use incident runbook prompts for live triage. Apply this prompt during the postmortem phase to prevent recurrence.

04

Poor Fit: Vendor-Specific SDK Configuration

Avoid when: you need exact configuration syntax for a specific message broker SDK, cloud queue service, or proprietary retry library. Guardrail: use the prompt for policy design principles, then translate the recommendations into your vendor's specific configuration schema manually or with a separate code-generation prompt.

05

Required Inputs

What you must provide: the message processing context (event handler, API call, or background job), expected processing latency, downstream dependency characteristics, and any existing SLA or SLO targets. Guardrail: missing latency or dependency data produces generic advice. Ground the prompt with real numbers from your observability platform.

06

Operational Risk: Poison Message Amplification

What to watch: the prompt may recommend retry strategies that amplify poison messages if max retry limits are too high or dead-letter routing is absent. Guardrail: always validate that the output includes explicit poison message detection criteria and dead-letter queue routing before implementing. Test with deliberately malformed payloads.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A copy-ready prompt template for generating a structured retry policy and backoff design review.

The prompt below is designed to be pasted directly into your AI system. It instructs the model to act as a Site Reliability Engineer reviewing a proposed retry and backoff strategy for an event-driven or distributed system. The template uses square-bracket placeholders for all variable inputs, such as the system description, current policy, and operational constraints. Replace each placeholder with your specific configuration before use.

text
You are a senior SRE reviewing a retry policy and backoff strategy for a distributed system.

Review the following design against best practices for resilience, thundering herd prevention, and poison message mitigation.

SYSTEM CONTEXT:
[SYSTEM_DESCRIPTION]

PROPOSED RETRY POLICY:
[RETRY_POLICY_DETAILS]

OPERATIONAL CONSTRAINTS:
[CONSTRAINTS]

OUTPUT_SCHEMA:
{
  "overall_assessment": "PASS | FAIL | NEEDS_CLARIFICATION",
  "critical_issues": [
    {
      "severity": "HIGH | MEDIUM | LOW",
      "category": "THUNDERING_HERD | POISON_MESSAGE | CIRCUIT_BREAKER | IDEMPOTENCY | TIMEOUT | OTHER",
      "description": "string",
      "recommendation": "string"
    }
  ],
  "backoff_algorithm_review": {
    "algorithm_type": "FIXED | LINEAR | EXPONENTIAL | DECORRELATED_JITTER | OTHER",
    "is_appropriate": "YES | NO | PARTIALLY",
    "reasoning": "string",
    "suggested_parameters": {
      "base_delay_ms": "number",
      "max_delay_ms": "number",
      "jitter_strategy": "FULL_JITTER | EQUAL_JITTER | DECORRELATED_JITTER | NONE"
    }
  },
  "max_retry_review": {
    "current_max_retries": "number",
    "is_safe": "YES | NO",
    "risk_of_amplification": "HIGH | MEDIUM | LOW",
    "suggested_max_retries": "number"
  },
  "circuit_breaker_assessment": {
    "is_configured": "YES | NO",
    "recommendation": "string"
  },
  "eval_checks": {
    "thundering_herd_risk": "HIGH | MEDIUM | LOW",
    "poison_message_amplification_risk": "HIGH | MEDIUM | LOW",
    "idempotency_required": "YES | NO",
    "timeout_configuration_safe": "YES | NO"
  },
  "revised_policy_suggestion": "string"
}

CONSTRAINTS:
- If the proposed policy is missing, assume a default of 3 retries with no backoff and flag it as a critical issue.
- Always recommend decorrelated jitter for distributed systems to prevent thundering herds.
- If a circuit breaker is not configured, flag it as a HIGH severity issue.
- If idempotency is not addressed, flag it as a HIGH severity issue for any system with at-least-once delivery.
- Provide a concrete, revised policy suggestion in the `revised_policy_suggestion` field.

To adapt this template, replace [SYSTEM_DESCRIPTION] with a concise summary of your architecture, including the message broker, consumer groups, and delivery guarantees. Replace [RETRY_POLICY_DETAILS] with your current or proposed configuration, such as "3 retries with a 1-second fixed delay." Replace [CONSTRAINTS] with any operational limits, such as maximum acceptable latency or data loss tolerance. The output schema is designed to be machine-readable for integration into automated design review pipelines. For high-risk systems where data loss or corruption is unacceptable, always route the AI's output to a human reviewer before implementing the revised policy.

IMPLEMENTATION TABLE

Prompt Variables

Every placeholder the Retry Policy and Backoff Design Prompt expects, why it matters, and how to validate it before sending the prompt.

PlaceholderPurposeExampleValidation Notes

[SYSTEM_DESCRIPTION]

Describes the message processing system, its reliability requirements, and the consequences of failure

Order fulfillment pipeline processing payment capture events with exactly-once delivery guarantees

Must be non-empty and include at least one reliability constraint. Reject if only contains generic system name

[FAILURE_SCENARIOS]

Lists specific failure modes the retry policy must handle, including transient errors, downstream timeouts, and poison messages

Payment gateway timeout (30s), inventory service 503, duplicate event detection failure, schema validation error

Must contain at least 3 distinct failure types. Validate each scenario includes error type and context. Reject if all scenarios are identical

[CURRENT_RETRY_CONFIG]

Documents the existing retry behavior including max attempts, backoff strategy, and timeout values

Max 3 retries, fixed 1s delay, no jitter, 5s total timeout, no circuit breaker

Must specify max attempts, delay strategy, and timeout. Accept null if designing from scratch. Validate numeric fields are positive

[THROUGHPUT_REQUIREMENTS]

Specifies the expected message volume, processing latency targets, and concurrency constraints

10,000 messages/minute peak, p99 processing latency under 2s, 50 concurrent consumer instances

Must include at least one quantitative metric. Validate throughput numbers are positive and latency targets are realistic for the system scale

[DEPENDENCY_SLAS]

Documents the availability targets, latency SLAs, and rate limits of downstream services the retry policy interacts with

Payment gateway: 99.9% availability, 500ms p95, 1000 req/s rate limit. Inventory service: 99.5% availability, 200ms p95

Must list at least one downstream dependency with availability target. Validate SLA percentages are between 0-100. Reject if no rate limit or latency information provided

[CONSTRAINTS]

Specifies operational constraints like max retry duration, idempotency requirements, and ordering guarantees

Total retry window under 60s, all handlers must be idempotent, per-partition ordering must be preserved

Must include at least one hard constraint. Validate idempotency requirement is explicitly stated. Reject if constraints contradict throughput requirements

[OUTPUT_FORMAT]

Defines the expected structure of the retry policy review output including required sections and decision rationale

JSON with sections: backoff_algorithm, max_retries, jitter_config, circuit_breaker_settings, dead_letter_routing, thundering_herd_mitigation

Must specify output structure. Validate required sections are present. Reject if output format is ambiguous or missing key retry policy components

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the retry policy prompt into an architecture review workflow or CI pipeline with validation, logging, and human review gates.

This prompt is designed to be integrated into a pre-merge architecture review pipeline, not used as a one-off chat interaction. The primary integration point is a CI check that runs when a pull request modifies retry configuration files (e.g., retry-policy.yaml, circuit-breaker.json, or application config blocks containing backoff parameters). The harness should extract the relevant configuration block, pass it as [POLICY_CONFIG] to the prompt, and treat the structured output as a review finding that can block the merge if critical issues are detected.

The implementation harness requires three components: a configuration extractor that parses the PR diff and isolates retry-related changes, a model invocation layer that sends the prompt with the extracted config and receives the structured JSON output, and a validation and gating layer that enforces review rules. The output schema should include a severity field (CRITICAL, WARNING, INFO) and a recommendation field. Configure the gating layer to block the merge on any CRITICAL finding—such as missing jitter, unbounded retry counts, or absent circuit breaker integration. WARNING findings (e.g., suboptimal backoff multiplier choice) should generate a non-blocking comment on the PR. The harness must also log the full prompt, response, and model version to an audit trail for post-incident review.

For model selection, use a model with strong reasoning capabilities and reliable JSON output (e.g., Claude 3.5 Sonnet or GPT-4o with structured outputs enabled). Set temperature to 0 to maximize consistency across runs. Implement a retry wrapper around the model call itself—if the model returns malformed JSON or fails to include required fields like severity, retry once with a repair prompt that includes the raw output and the expected schema. If the second attempt also fails, escalate to a human reviewer via a PR comment and a Slack notification. Do not silently skip the check. For high-risk systems (payment processing, healthcare, critical infrastructure), always require human approval on any finding before the PR can merge, regardless of severity classification.

Before deploying this harness to production, validate it against a golden dataset of known retry configurations: one with correct exponential backoff and jitter, one with missing jitter, one with unbounded retries, and one with a misconfigured circuit breaker. Confirm that the harness correctly blocks, warns, or passes each case. Monitor the harness in production for false positive rates—if the model consistently flags a team's standard pattern as CRITICAL, adjust the prompt's [CONSTRAINTS] or add a [CONTEXT] block with organization-specific policies. The harness should also track latency; if the model call exceeds five seconds, consider caching common configuration patterns or switching to a faster model for non-critical reviews.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, types, and validation rules for the structured retry policy review output. Use this contract to parse and validate the model response before integrating it into downstream systems.

Field or ElementType or FormatRequiredValidation Rule

retry_policy_review

object

Top-level object must be present and parseable as JSON

retry_policy_review.summary

string

Non-empty string; max 500 characters; must not contain unresolved placeholders

retry_policy_review.backoff_algorithm

string

Must match one of: exponential, linear, fixed, jittered, decorrelated, custom

retry_policy_review.max_retries

integer

Must be >= 0; if 0, retry_policy_review.retry_enabled must be false

retry_policy_review.jitter_config

object

Must contain jitter_config.enabled (boolean) and jitter_config.strategy (string: full, equal, decorrelated, none)

retry_policy_review.circuit_breaker

object

Must contain circuit_breaker.enabled (boolean); if true, must include failure_threshold (integer > 0) and cooldown_seconds (integer >= 0)

retry_policy_review.thundering_herd_risk

string

Must match one of: low, medium, high, critical; if high or critical, retry_policy_review.mitigations array must not be empty

retry_policy_review.poison_message_risk

string

Must match one of: low, medium, high, critical; if high or critical, retry_policy_review.dead_letter_strategy must be present

PRACTICAL GUARDRAILS

Common Failure Modes

Retry and backoff logic is deceptively simple. Most failures in production aren't from the algorithm choice but from systemic amplification of small problems. Here's what breaks first and how to guard against it.

01

Thundering Herd After Broker Outage

What to watch: When a message broker recovers, all consumers with identical backoff timers reconnect simultaneously, overwhelming the broker and triggering another outage. Guardrail: Add random jitter to reconnection backoff and stagger client initialization. Validate with a chaos test that simulates a full broker restart.

02

Poison Message Amplification

What to watch: A malformed message that always fails processing gets retried indefinitely, consuming resources and blocking the queue. Without a dead-letter queue (DLQ), one bad message can stall an entire pipeline. Guardrail: Enforce a hard max-retry limit and route unprocessable messages to a DLQ with alerting. Never retry on schema validation failures.

03

Exponential Backoff Without a Ceiling

What to watch: Unbounded exponential backoff (e.g., doubling delay indefinitely) can lead to retry intervals of hours or days, making the system appear hung. Operators may restart services unnecessarily. Guardrail: Cap the maximum backoff interval (e.g., 5 minutes) and log a clear state transition when the cap is reached so monitoring can distinguish 'waiting' from 'stuck'.

04

Idempotency Key Collisions on Retry

What to watch: Retrying a non-idempotent operation (e.g., sending an email or creating a charge) with the same payload duplicates the side effect. This is the most common cause of double-billing incidents. Guardrail: Require idempotency keys on all retryable operations. The handler must check the key before executing the side effect. Test by replaying the same message twice and asserting exactly-once outcomes.

05

Retry Storms Masking Downstream Degradation

What to watch: When a downstream service slows down, aggressive retries multiply the load, turning a latency problem into a full outage. The retry policy becomes the attack vector. Guardrail: Combine retries with a circuit breaker. If the failure rate exceeds a threshold, stop retrying and fail fast. Monitor retry amplification factor (retry attempts / initial attempts) and alert on spikes.

06

Timeout Mismatch Between Retry and Operation

What to watch: A retry timeout shorter than the operation's expected latency causes every attempt to time out, exhausting retries before any request could succeed. Guardrail: Set the per-attempt timeout to the operation's P99 latency plus headroom. Ensure the total retry budget (attempts × timeout) is less than the caller's timeout to avoid orphaned work.

IMPLEMENTATION TABLE

Evaluation Rubric

How to test output quality before shipping this prompt into your review workflow.

CriterionPass StandardFailure SignalTest Method

Backoff algorithm specification

Output names a concrete algorithm (exponential, linear, decorrelated jitter) with base delay and multiplier values

Vague description like 'use exponential backoff' without parameters or 'back off appropriately'

Parse output for algorithm name, base delay, and multiplier; assert all three present

Max retry limit definition

Output specifies a numeric max retry count or total time budget with rationale tied to system SLA

Unbounded retry recommendation, missing max limit, or limit without SLA justification

Regex extract max retry number or time budget; assert value > 0 and rationale sentence present

Jitter configuration

Output includes jitter type (full, equal, decorrelated) and explains how it prevents thundering herd

No jitter mentioned, or jitter mentioned without connection to thundering herd or contention

Keyword check for 'jitter' plus causal explanation linking to thundering herd or contention reduction

Circuit breaker integration

Output describes circuit breaker state transitions (closed, open, half-open) and how retries interact with each state

Retry policy described in isolation without circuit breaker interaction, or circuit breaker mentioned without state model

Check for presence of at least two circuit breaker states and retry behavior per state

Poison message handling

Output identifies poison message scenario and proposes dead-letter routing with alerting threshold

Retry policy that would retry poison messages indefinitely, or no dead-letter mechanism described

Keyword check for 'dead letter' or 'DLQ' plus alerting threshold or manual review trigger

Idempotency requirement

Output states that retried operations must be idempotent and identifies idempotency key strategy

No mention of idempotency, or assumes operations are naturally idempotent without verification

Keyword check for 'idempotent' plus concrete key strategy (e.g., request ID, event ID, idempotency key)

Retry amplification risk

Output calculates worst-case retry amplification factor and proposes consumer-side limits

No amplification analysis, or retry policy that could cause exponential message multiplication across consumers

Check for numeric amplification factor or consumer-side concurrency limit tied to retry behavior

Observability and logging

Output specifies what to log per retry attempt (attempt number, delay, error type, correlation ID)

No logging guidance, or logging recommendation that would miss root cause (e.g., only logging final failure)

Check for per-attempt log fields list including attempt number, delay, and error type or correlation ID

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt but remove strict output schema requirements. Replace [OUTPUT_SCHEMA] with a looser instruction like "Return a bulleted list of recommendations." Reduce [CONSTRAINTS] to only the most critical rules (e.g., max retries and backoff type). Skip eval harness wiring.

Watch for

  • Overly broad recommendations without specific backoff algorithm parameters
  • Missing jitter configuration advice
  • No distinction between transient and permanent failure handling
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.