Inferensys

Prompt

Saga Orchestration Design Evaluation Prompt

A practical prompt playbook for using the Saga Orchestration Design Evaluation Prompt in production AI workflows to critique compensation logic, idempotency, timeout handling, and failure modes.
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

Define the job, reader, and constraints for the Saga Orchestration Design Evaluation Prompt.

Use this prompt when you are an engineer or architect reviewing a long-running transaction design that spans multiple services, databases, or bounded contexts. The job-to-be-done is a structured critique of a saga's orchestration logic, focusing on compensation, idempotency, timeout handling, and failure modes. You should have a concrete saga design in front of you—whether as a sequence diagram, a written specification, or a code skeleton—and you need a systematic evaluation before the design reaches implementation or code review. This prompt is not for greenfield saga design from scratch; it assumes a design exists and needs a rigorous review.

The ideal user is a backend engineer, platform engineer, or architect who understands distributed transactions and has already sketched out the saga steps, participant services, and compensating actions. Required context includes the saga's trigger, the sequence of local transactions, the compensation path for each step, timeout policies, and any retry or idempotency mechanisms. If you are missing these details, the prompt will produce a low-confidence critique full of assumptions. Do not use this prompt for simple request-response workflows, single-service transactions, or synchronous API chains that lack explicit compensation logic—those do not constitute sagas and will produce irrelevant output.

This prompt is also inappropriate when you need a production-grade formal verification of a saga's correctness. The model can identify missing compensation steps, flag timeout gaps, and surface idempotency risks, but it cannot prove liveness or safety properties. For high-risk financial, healthcare, or compliance-critical sagas, treat the model's output as a design review aid, not a replacement for peer review, formal modeling, or failure injection testing. The output should feed into your team's architecture decision process, not serve as the final sign-off.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works, where it fails, and the operational prerequisites for production use.

01

Good Fit: Greenfield Saga Design

Use when: You are designing a new long-running transaction from scratch and need a structured critique of compensation logic, idempotency keys, and timeout handling before writing code. Guardrail: Provide the full sequence of steps, participant services, and expected failure modes in the input context.

02

Good Fit: Pre-Implementation Review

Use when: An engineer has drafted a saga orchestration flow and needs a second-order review for missing rollback steps, retry storms, or ordering dependencies. Guardrail: Pair the prompt output with a human architecture review; the model identifies patterns but cannot validate business invariants.

03

Bad Fit: Runtime Orchestration

Avoid when: You need a live orchestrator to execute sagas in production. This prompt produces a design critique, not a runtime engine. Guardrail: Use a dedicated saga framework (Cadence, Temporal, or custom state machine) for execution; use this prompt only for design review.

04

Bad Fit: Undocumented Legacy Systems

Avoid when: The saga spans services with unknown failure modes, undocumented side effects, or implicit state. Guardrail: The model cannot infer hidden coupling. Require documented API contracts, timeout behaviors, and idempotency guarantees for each participant before using this prompt.

05

Required Inputs

What you must provide: A complete list of saga steps in order, each step's participant service, compensation action, expected latency, idempotency mechanism, and timeout. Guardrail: Missing any of these fields produces a shallow critique. Use a structured input template to enforce completeness before invoking the prompt.

06

Operational Risk: Overconfidence on Edge Cases

Risk: The model may confidently assert correctness for partial failure scenarios, network partitions, or duplicate events that it has not fully reasoned about. Guardrail: Treat every identified gap as a prompt for deeper human analysis, not a resolved finding. Log model critiques as review triggers, not approvals.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for evaluating saga orchestration designs with square-bracket placeholders for your specific inputs.

This prompt template is designed to evaluate a saga orchestration design by systematically analyzing its compensation logic, idempotency guarantees, timeout handling, and failure modes. The template uses square-bracket placeholders so you can inject your own saga specification, domain constraints, and output format requirements without rewriting the core evaluation logic. Before using this prompt, gather your saga definition—including the sequence of steps, their compensating actions, and any state machine or orchestrator logic—so the model has enough detail to produce a meaningful critique.

text
You are a senior backend architect specializing in distributed systems and long-running transaction patterns. Your task is to evaluate a saga orchestration design and produce a structured critique.

## INPUT
[SAGA_DEFINITION]

## CONSTRAINTS
[CONSTRAINTS]

## OUTPUT SCHEMA
You must return a valid JSON object with the following structure:
{
  "overall_assessment": "PASS | FAIL | NEEDS_REVIEW",
  "summary": "One-paragraph summary of the design's strengths and weaknesses.",
  "compensation_review": {
    "missing_compensations": ["step_name or description of missing rollback"],
    "compensation_order_issues": ["description of ordering problems"],
    "partial_failure_handling": "Assessment of how the design handles partial completion during rollback."
  },
  "idempotency_review": {
    "idempotent_steps": ["steps that are idempotent"],
    "non_idempotent_steps": ["steps lacking idempotency guarantees"],
    "duplicate_execution_risks": ["scenarios where duplicate execution could cause harm"]
  },
  "timeout_and_retry_review": {
    "timeout_configuration": "Assessment of timeout values per step and overall saga.",
    "retry_policy": "Assessment of retry strategy, backoff, and max attempts.",
    "stuck_saga_risks": ["scenarios where the saga could hang indefinitely"]
  },
  "failure_mode_analysis": [
    {
      "failure_scenario": "Description of a specific failure.",
      "impact": "What happens in the current design.",
      "recommendation": "How to mitigate or handle this failure."
    }
  ],
  "missing_concerns": ["Any cross-cutting concerns not addressed in the design."],
  "recommendations": ["Actionable, prioritized recommendations for improvement."]
}

## EVALUATION CRITERIA
1. Every forward step must have a defined compensating action or a documented reason why compensation is unnecessary.
2. Every step must be idempotent or include a deduplication mechanism.
3. Timeouts must be defined per step and for the overall saga execution.
4. The design must specify what happens when a compensation step itself fails.
5. The saga must have a terminal state for every possible execution path.

## INSTRUCTIONS
- Be specific. Reference step names and sequences from the provided saga definition.
- Flag missing compensations explicitly, even if the design implies they exist.
- If the saga uses choreography instead of orchestration, note the additional risks around distributed state tracking.
- If the design is incomplete, set overall_assessment to NEEDS_REVIEW and explain what information is missing.
- Do not invent steps or compensations that are not described in the input.

To adapt this template, replace [SAGA_DEFINITION] with your full saga specification—including step names, their order, compensating actions, timeout values, retry policies, and the orchestrator or choreography mechanism. Replace [CONSTRAINTS] with any domain-specific rules such as "all steps must complete within 30 seconds" or "compensation steps must not call external payment gateways." If your team uses a specific output format, adjust the OUTPUT SCHEMA block to match your internal review template. For high-risk financial or healthcare sagas, add a [RISK_LEVEL] placeholder and instruct the model to escalate findings that could cause data inconsistency or financial loss. After generating the critique, always have a senior engineer review the findings before accepting or rejecting the recommendations—the model can miss subtle interaction effects between timeout configurations and retry policies that only manifest under production load.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Saga Orchestration Design Evaluation Prompt. Each placeholder must be populated before the prompt is sent. Missing or malformed inputs are the most common cause of incomplete evaluations.

PlaceholderPurposeExampleValidation Notes

[SAGA_DESCRIPTION]

Full narrative of the long-running transaction, including all steps, participants, and the business goal

Order fulfillment saga: ReserveInventory → ChargePayment → ShipOrder → NotifyCustomer. Compensation: ReleaseInventory, RefundPayment, CancelShipment

Must be >= 200 characters. Reject if only a diagram reference or URL is provided. Parse check for step enumeration.

[COMPENSATION_PLAN]

Explicit rollback or undo steps for each forward action in the saga

ReserveInventory → ReleaseInventory; ChargePayment → RefundPayment; ShipOrder → CancelShipment

Must pair each forward step with a compensation. Missing pairs trigger a FAIL in the eval. Schema check: array of {forward, compensation} objects.

[IDEMPOTENCY_STRATEGY]

How each step and compensation handles duplicate execution or retry

Payment service uses idempotency keys; Inventory uses compare-and-swap on version field; Shipment uses order_id as dedup key

Must cover every step. Null allowed only if explicitly documented as 'not implemented'. Confidence threshold: reject if strategy is 'we handle it in code' without specifics.

[TIMEOUT_CONFIG]

Timeout durations and retry policies per step, including max retries and backoff

ReserveInventory: 5s timeout, 3 retries with exponential backoff; ChargePayment: 10s timeout, 2 retries; ShipOrder: 30s timeout, 1 retry

Must specify timeout per step. Reject if only a global default is provided. Parse check for numeric timeout values and retry counts.

[FAILURE_MODES]

Known failure scenarios for each step, including transient, permanent, and partial failures

Inventory: insufficient stock (permanent), DB timeout (transient); Payment: declined (permanent), gateway timeout (transient); Shipment: warehouse unavailable (transient), invalid address (permanent)

Must classify each failure as transient or permanent. Missing classification triggers a warning. Schema check: array of {step, failure, type, impact} objects.

[STATE_PERSISTENCE]

How saga state is stored, queried, and recovered after process crashes

Saga state stored in Postgres saga_instance table with step_status JSONB column. Recovery polls for instances in 'in_progress' state older than 2x max timeout.

Must describe storage mechanism and recovery process. Reject if state is only in-memory. Approval required if state store is the same database as business data without isolation rationale.

[ORCHESTRATOR_DESIGN]

Architecture of the saga coordinator: centralized orchestrator, choreography, or hybrid

Centralized orchestrator as a dedicated service with its own database. Communicates with participants via async messaging over RabbitMQ. No synchronous HTTP calls between participants.

Must specify coordination model and communication protocol. Reject if 'both' is claimed without explicit boundaries. Parse check for protocol names and coupling description.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the saga evaluation prompt into a design review workflow with validation, retries, and human approval gates.

This prompt is designed to run as part of a pre-implementation design review gate, not as a runtime decision engine. Wire it into a pull request workflow, an architecture review checklist, or a design document pipeline where engineers submit saga specifications before coding begins. The prompt expects a structured saga definition as input—typically a JSON or YAML document describing steps, compensation actions, timeouts, retry policies, and participant services. If your team maintains saga definitions in a registry or design tool, extract the relevant specification and pass it as [SAGA_SPECIFICATION]. The [CONSTRAINTS] placeholder should carry your organization's specific policies: maximum saga duration, required idempotency guarantees, approved compensation patterns, and any regulatory requirements around transaction integrity.

Model choice matters here. Use a model with strong reasoning capabilities (GPT-4o, Claude 3.5 Sonnet, or Gemini 1.5 Pro) because the evaluation requires multi-step causal reasoning about failure propagation and compensation ordering. Avoid smaller or faster models that may miss subtle failure mode interactions. Validation layer: Parse the model's JSON output immediately and validate that all required fields are present (saga_id, findings, severity, recommendation, missing_compensations, idempotency_gaps, timeout_risks). If validation fails, retry once with the validation errors appended to the prompt as feedback. If the second attempt also fails, flag the review for human triage—do not silently accept incomplete evaluations. Logging: Capture the full prompt, model response, validation result, and any retry attempts in your design review audit trail. This is critical for governance if a saga defect reaches production.

Human approval gate: All findings with severity: critical or severity: high should block automated approval and require a human architect to acknowledge or override. Implement this as a status check in your review system—the prompt output should set a requires_human_review boolean that your workflow engine respects. For lower-severity findings, you can auto-approve but still surface them in the design document as review comments. Tool integration: If your saga definitions reference external service contracts, consider augmenting this prompt with a retrieval step that pulls the latest API specs or SLA documents for those services before evaluation. This grounds the timeout and idempotency checks in actual service guarantees rather than assumptions. What to avoid: Do not use this prompt as a runtime saga executor or decision maker. It evaluates designs, not live transactions. Do not skip the human review gate for critical findings—saga failures in production can cause data corruption that is expensive to repair.

IMPLEMENTATION TABLE

Expected Output Contract

Expected fields, types, and validation rules for the saga orchestration design evaluation output. Use this contract to parse, validate, and route the model response before downstream consumption.

Field or ElementType or FormatRequiredValidation Rule

saga_name

string

Non-empty string; must match [SAGA_NAME] input if provided

overall_risk_score

string

Must be one of: low, medium, high, critical; case-insensitive match

compensation_audit

array of objects

Each object must contain step_id (string), has_compensation (boolean), compensation_step (string|null), gap_description (string|null)

idempotency_assessment

object

Must contain overall_score (low|medium|high|critical), missing_idempotency_keys (array of strings), duplicate_risk_steps (array of strings)

timeout_handling_review

object

Must contain global_timeout_defined (boolean), per_step_timeouts (array of objects with step_id and timeout_seconds or null), orphan_step_risks (array of strings)

failure_mode_analysis

array of objects

Each object must contain step_id (string), failure_scenario (string), blast_radius (string), recovery_path (string), severity (low|medium|high|critical)

missing_rollback_steps

array of strings

Array of step_id values that lack compensation; empty array allowed if none missing

recommendations

array of strings

Minimum 1 recommendation if overall_risk_score is high or critical; each string non-empty and actionable

PRACTICAL GUARDRAILS

Common Failure Modes

Saga orchestration prompts fail in predictable ways. These cards cover the most common failure modes when using LLMs to evaluate long-running transaction designs, along with concrete guardrails to catch them before they reach production.

01

Missing Compensation Steps

What to watch: The model accepts a saga step without a corresponding compensating action, especially for non-obvious side effects like cache updates, analytics events, or third-party webhooks. Guardrail: Require the prompt to output a compensation matrix mapping every forward step to its rollback action, and flag any step with a null compensation entry for human review.

02

Idempotency Overconfidence

What to watch: The model assumes idempotency keys or retry logic will handle all duplicate scenarios without checking whether downstream services actually support idempotent operations. Guardrail: Add a constraint that forces the prompt to list the idempotency guarantee for each participant service, and mark any unverified claim as a risk requiring explicit confirmation from the service owner.

03

Timeout Cascade Blindness

What to watch: The model evaluates timeout values in isolation without modeling how nested timeouts compound across saga steps, leading to total execution windows that exceed caller deadlines. Guardrail: Instruct the prompt to calculate the worst-case cumulative timeout across the full saga chain and compare it against the upstream SLA, flagging any violation as a blocking issue.

04

Partial Failure State Drift

What to watch: The model treats saga state as binary (success/failure) and misses scenarios where a step partially completes, leaving the system in an inconsistent state that neither the forward path nor the compensation path can cleanly recover. Guardrail: Require the prompt to enumerate intermediate states for each step and verify that every reachable state has a defined recovery path, not just the terminal states.

05

Compensation Order Reversal

What to watch: The model suggests compensating actions in the wrong order, undoing later steps before earlier ones and violating dependency constraints that existed in the forward execution. Guardrail: Add a validation rule that the compensation sequence must be the exact reverse of the forward execution order, and require the prompt to justify any deviation with explicit dependency reasoning.

06

Hallucinated Participant Contracts

What to watch: The model invents API endpoints, message schemas, or participant capabilities that don't exist in the actual system, producing a design that looks coherent but can't be implemented. Guardrail: Constrain the prompt to reference only participants and contracts provided in the input context, and add a grounding check that flags any participant or operation not explicitly listed in the source material.

IMPLEMENTATION TABLE

Evaluation Rubric

Criteria for evaluating the quality of a saga orchestration design critique before integrating the prompt into a design review pipeline. Use these checks to gate the prompt's output before a human architect reviews it.

CriterionPass StandardFailure SignalTest Method

Compensation Completeness

Every forward step in the saga has a corresponding compensation action defined in the output

Output lists a forward step without a matching rollback or explicitly marks it as non-compensable with a justification

Parse the output into a list of steps and compensations; assert that the set of forward step IDs is a subset of the set of compensation step IDs plus any documented non-compensable exceptions

Idempotency Analysis

Output identifies at least one idempotency risk per participant and proposes a specific idempotency key or strategy

Output mentions idempotency only in general terms without mapping keys to specific participants or operations

Search output for participant names and verify each has a corresponding idempotency key field or a documented reason for exclusion

Timeout Handling

Output specifies a timeout value and a timeout handler for every external service call in the saga

Output uses generic language like 'add timeouts' without concrete values or handler descriptions

Extract all external service calls from the design; assert each has a timeout duration and a handler action in the output

Failure Mode Enumeration

Output covers at least three distinct failure categories: transient, permanent, and partial completion

Output only describes a single 'failure' scenario or conflates transient and permanent failures

Classify failure descriptions in the output by type; assert at least one example exists for transient, permanent, and partial completion categories

Orchestrator State Persistence

Output describes where the orchestrator stores saga state and how it recovers after an orchestrator crash

Output assumes the orchestrator is always available or stores state only in memory

Search output for state persistence mechanism and recovery procedure; assert both are present and reference a concrete storage location

Isolation Concern Identification

Output identifies at least one isolation anomaly possible in the design and proposes a semantic lock or countermeasure

Output does not mention isolation, dirty reads, or lost updates between saga participants

Search output for isolation-related terms; assert at least one anomaly is named and paired with a mitigation strategy

Retry Policy Specification

Output defines a retry policy with max attempts and backoff strategy for each transient-failure-prone step

Output says 'retry on failure' without specifying attempt limits or backoff behavior

Parse retry configurations from the output; assert each retry policy includes a max attempts integer and a backoff type

Source Grounding

Every design critique references a specific line, diagram element, or named component from the input design

Output contains generic architecture advice without citing any specific element from the provided design

Sample three critique statements from the output; assert each contains a direct reference to a named element from the input context

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Add strict JSON output schema with fields: saga_id, critique_items[], severity, compensation_gaps[], idempotency_issues[], timeout_risks[], recommended_fixes[]. Wrap the prompt in a retry loop that validates schema compliance. Add a pre-processing step that extracts saga steps from your orchestration config or state machine definition into the [SAGA_DEFINITION] placeholder. Log every evaluation with the model version and prompt hash.

Watch for

  • Silent format drift between model versions
  • Missing compensation_gaps when compensations exist but are incomplete
  • The model accepting a saga without checking that every forward step has a defined rollback
  • Overconfidence in severity scoring without evidence
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.