Scripts
AuraScore 83/100

Human-in-the-Loop Agent Workflow Chain Definition Script

Develop a stateful workflow script that coordinates autonomous agent actions, interruptible approval gates, and escalation routines.

Use this template when implementing autonomous workflows that require human oversight before committing high-stakes tool actions. It generates a full state machine script with pause-and-resume capability.

Template

Role: Lead Autonomous Workflow Systems Engineer specializing in durable execution engines, human-in-the-loop systems, and agent governance.

Context

  • Workflow Engine: {{orchestration_engine}}
  • Target Enterprise Process: {{business_process}}
  • Unattended Execution Steps: {{autonomous_steps}}
  • Supervised Approval Gates: {{approval_gates}}
  • Escalation and Rejection Handling: {{error_handling_matrix}}
  • Privacy and Payload Policies: {{context_retention_rules}}

Task

Author a durable workflow chain script using {{orchestration_engine}} that executes {{business_process}}, isolating {{autonomous_steps}} while enforcing interruptible review gates, timeout escalations, and compensation logic for {{approval_gates}}.

Method

  1. Define durable state models that persist execution history, pending approvals, and intermediate results.
  2. Implement async workers for {{autonomous_steps}} with deterministic idempotency keys.
  3. Design interruptible workflow checkpoints for actions listed in {{approval_gates}}, pausing workflow execution.
  4. Build signal listeners that process human decisions (approve, modify parameters, reject) with audit metadata.
  5. Implement a sanitization filter applying {{context_retention_rules}} to payload data before presenting it to human reviewers.
  6. Construct compensation routines in the event of human rejection or downstream tool failure per {{error_handling_matrix}}.
  7. Implement timeout timers that trigger secondary escalations if an approval gate remains unaddressed.
  8. Expose an external resume endpoint handler that safely continues state execution upon receipt of a valid signal.

Constraints

  • The script MUST implement native pause/resume capabilities supported by {{orchestration_engine}} rather than busy-wait loops.
  • Sensitive data MUST NOT be exposed in human-facing review payloads without passing through {{context_retention_rules}} filters.
  • Approval gate timeouts must execute explicit fallback or rollback paths defined in {{error_handling_matrix}}.
  • Every human action (approval, parameter amendment, rejection) must be recorded in an immutable audit log state.

Output format

Provide the response structured as follows:

  1. State Model & Interface Definitions (Data classes and event signals)
  2. Durable Workflow Definition Script (Complete workflow class, activity handlers, interrupt checkpoints, and compensation loops)
  3. Signal Dispatch Example (A client script demonstrating how an external human review UI pauses, inspects, and resumes the flow)

Self-review

  • Verify that every gate in {{approval_gates}} requires an explicit external signal before triggering downstream tools.
  • Confirm that no state transition occurs without persisting trace data compliant with {{context_retention_rules}}.
  • Ensure timeout triggers accurately invoke the escalation pathways outlined in {{error_handling_matrix}}.
AuraScore breakdown
83/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.

Robustness5/5 · Strong

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

writing-content
writing-scripts
autonomous-agents-workflows
human-in-the-loop
workflow-chains
state-machines