Workflow chains
AuraScore 81/100

Distributed Saga Workflow Specification for Agentic Microservices

Design a resilient multi-step saga workflow chain with automated compensation logic for distributed agent tasks.

Use this template when designing fault-tolerant multi-agent orchestrations that execute stateful operations across multiple software services. It delivers a formal specification outlining forward execution steps, state persistence checkpoints, and rollback transactions.

Template

Role: Principal Distributed Systems Architect with 15+ years of experience in microservices orchestration and fault-tolerant agent execution.

Context

  • Target Orchestration Engine: {{orchestration_engine}}
  • Sequential Agent Workflow Steps: {{primary_agent_steps}}
  • Shared State Store: {{state_store}}
  • High-Risk Failure Modes: {{failure_modes}}
  • Retry and Backoff Policy: {{retry_policy}}
  • Ops Notification Channel: {{notification_channel}}

Task

Author a production-ready Distributed Saga Workflow Specification that defines the deterministic orchestration sequence, forward transaction contracts, compensating actions for failures, and state persistence rules across {{primary_agent_steps}} using {{orchestration_engine}}.

Method

  1. Analyze {{primary_agent_steps}} and map each step to an explicit atomic transaction boundary.
  2. Define the payload structure and state delta committed to {{state_store}} at each transition step.
  3. Identify failure triggers per step based on {{failure_modes}} and categorize them into retryable vs fatal errors.
  4. Apply {{retry_policy}} to transient failures, defining jitter, maximum attempts, and timeout budgets.
  5. Design compensating rollback actions for each completed step in reverse order when a non-retryable failure occurs.
  6. Specify idempotency mechanisms (e.g., deduplication keys, token checking) for both forward and compensating tasks.
  7. Establish dead-letter queue (DLQ) ingestion and alerting workflows routed to {{notification_channel}}.

Constraints

  • MUST define explicit backward compensating logic for every forward-executing agent task.
  • MUST NOT leave state transitions uncommitted between step boundaries in {{state_store}}.
  • Every transaction boundary MUST specify maximum timeout durations and retry ceilings.
  • Specifications must avoid vague pseudo-code; use structured schema definitions.

Output format

  1. Workflow Topology Overview (Mermaid sequence diagram and state machine definition, max 30 lines)
  2. Step-by-Step Step Contract Table (Step ID, Agent Role, Forward Action, Idempotency Key, Timeout)
  3. Compensation Matrix (Failure Trigger, Rollback Action, Target Microservice, Invariant Validation)
  4. State Persistence & Telemetry Specification (JSON schema for {{state_store}} state object, DLQ routing to {{notification_channel}})

Self-review

  • Verify every forward step has a corresponding, executable compensating step.
  • Confirm all variables from context ({{orchestration_engine}}, {{state_store}}, etc.) are mapped into the specification.
  • Check that the idempotency mechanism prevents double-spend or duplicate mutation during retries.
AuraScore breakdown
81/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering12/12 · Strong

Hard boundaries — what the model must and must not do.

Output specification6/14 · Thin

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency5/10 · Thin

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness3/5 · Adequate

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

ai-agents
agents-workflows
software-engineering-debugging
saga-pattern
orchestration
fault-tolerance