Xpersona
D

Durable Workflow

CLAWHUB · Unverified

Patterns and procedures for building AI agent workflows that survive real-world failures. Use when asked to build a multi-step automation, pipeline, or agent... Skill: Durable Workflow Owner: old-greggyboy Summary: Patterns and procedures for building AI agent workflows that survive real-world failures. Use when asked to build a multi-step automation, pipeline, or agent... Tags: latest:1.0.1 Version history: v1.0.1 | 2026-03-24T22:05:05.855Z | auto v1.0.1 of durable-workflow - No file changes detected in this version. - No user-facing updates or documentation changes. v1.0.0

62
Rank
84
Safety
1.1k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.1K downloads reported by the source. Last updated 10/11/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s175wg8gt8gbcdafp6w5d0s7gh83gsp5:durable-workflow
  1. Setup complexity is classified as HIGH. You must provision dedicated cloud infrastructure or an isolated VM. Do not run this directly on your local workstation.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-old-greggyboy-durable-workflow/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

26,491 characters of source documentation, loaded on request.

Extracted files

4 files captured from the source.

SKILL.md

---
name: durable-workflow
description: |
  Patterns and procedures for building AI agent workflows that survive real-world failures. Use when asked to build a multi-step automation, pipeline, or agent workflow — especially when it involves external APIs, file operations, long-running tasks, or anything that must not lose state. Triggers on: "automate", "pipeline", "workflow", "agent loop", "multi-step", "background task", "retry", "error handling", "won't lose progress", "keeps failing", "handle errors", "resilient", or any request to build an automation that must stay running.
---

# Durable Workflow Patterns

Build automations that survive API failures, timeouts, and unexpected state — without rebuilding from scratch every time something breaks.

## Core Principle

Every step in a multi-step workflow must answer three questions:
1. **What did I finish?** (checkpoint)
2. **What do I do if this step fails?** (recovery)
3. **Who finds out if something goes wrong?** (alerting)

Skip any of these and the workflow will eventually fail silently.

## Scripts

Ready-to-use implementations in `scripts/`:

| Script | Purpose |
|--------|---------|
| `workflow-template.js` | Complete workflow skeleton with checkpoints, retry, DLQ, exit handler |
| `lock.js` | File-based process lock — prevents concurrent runs |

### workflow-template.js

Copy and fill in the step TODOs:

```bash
cp scripts/workflow-template.js my-workflow.js
node my-workflow.js           # Run (or re-run — resumes from last checkpoint)
WORKFLOW_STATE_PATH=/tmp/state.json node my-workflow.js   # Custom state path
```

Features: atomic state saves, exponential backoff, timeout wrapper, DLQ, abnormal-exit logging.

### lock.js

Prevent two instances of the same workflow from running at once:

```javascript
const { withLock, LockError } = require('./lock');

withLock('/tmp/my-workflow.lock', async () => {
  // Only one process runs this block at a time
  await runWorkflow();
}).catch(e => {
  if (e.name === 'LockError') {
    console.error('Already running:', e.message);
  } else {
    throw e;
  }
});
```

## Pattern 1: Checkpoint State

Save progress after every meaningful step. Never trust in-memory state across network calls.

```javascript
// checkpoint.js pattern
const state = loadState('workflow-id') || { step: 0, results: [] };

if (state.step < 1) {
  state.results.push(await fetchData());
  state.step = 1;
  saveState('workflow-id', state);
}
if (state.step < 2) {
  state.results.push(await processData(state.results[0]));
  state.step = 2;
  saveState('workflow-id', state);
}
// Restart from any step — already-done steps are skipped
```

## Pattern 2: Circuit Breaker

Stop hammering a failing service. Open the circuit after N failures, half-open after a cooldown.

```javascript
class CircuitBreaker {
  constructor(threshold = 3, cooldownMs = 30000) {
    this.failures = 0; this.threshold = threshold;
    this.state = 'closed'; this.nextRetry = 0;
  }
  async call(fn) {
    if (this.

_meta.json

{
  "ownerId": "kn7348wh74j9bf7af0y2d9k20182zjny",
  "slug": "durable-workflow",
  "version": "1.0.1",
  "publishedAt": 1774389905855
}

references/failure-taxonomy.md

# Agent Workflow Failure Taxonomy

Common failure modes, how to diagnose them, and the fix pattern.

## Silent Failures

**Symptoms:** Workflow reports success, nothing was actually done. Logs show "completed" but output is empty or stale.

**Causes:**
- Exception caught but not re-thrown or logged
- API returned 200 with an error payload that wasn't checked
- Async function called without `await`

**Fix:** Log every caught exception. Check API response bodies, not just status codes. Lint for missing `await`.

---

## Phantom Retries

**Symptoms:** Items processed multiple times. Duplicate records, double-sends, duplicate charges.

**Causes:**
- No idempotency key on API calls
- Retry logic re-runs from the beginning instead of from the failed step
- State saved after the step instead of before marking complete

**Fix:** Use deterministic IDs (hash of input) as idempotency keys. Save state *before* marking a step done, not after.

---

## Cascading Timeouts

**Symptoms:** One slow API call causes all downstream steps to hang. Entire workflow stalls.

**Causes:**
- No timeout set on external calls
- No circuit breaker — keeps retrying a down service
- Blocking operations on the main thread

**Fix:** Set explicit timeouts on all fetch/HTTP calls. Circuit breaker with a sensible cooldown. Treat timeout as a failure, not a slow success.

---

## State Drift

**Symptoms:** Workflow thinks step 3 is done but step 2's output was corrupt. Later steps produce garbage.

**Causes:**
- State file written but not validated after write
- Partial writes on crash (file truncated)
- Multiple workflow instances writing the same state file

**Fix:** Validate state after loading (check schema, not just existence). Use atomic writes (write to temp file, rename). Add instance lock file.

---

## Context Window Saturation (LLM-specific)

**Symptoms:** Agent starts dropping earlier context, makes decisions inconsistent with prior steps, "forgets" tool outputs.

**Causes:**
- Accumulating raw API responses in context instead of summaries
- No compaction between workflow phases

**Fix:** Summarize tool outputs immediately after use. Between major phases, compact context. Store raw data in files, keep only references in context.

---

## Tool Call Loops

**Symptoms:** Agent calls the same tool repeatedly with slightly different arguments. Burns tokens, never progresses.

**Causes:**
- No loop guard (no check for "did I already try this?")
- Tool returns ambiguous result, agent re-queries instead of deciding
- Missing stopping condition in the workflow instructions

**Fix:** Track tool calls made in current session. Add explicit stopping conditions: "if you've called X more than 3 times on the same input, stop and report what you have."

---

## Rate Limit Spiral

**Symptoms:** Workflow hits 429, backs off, retries, hits 429 again. Exponential delay keeps growing. Workflow never completes.

**Causes:**
- Parallel requests to rate-limited API
- Retry adds to the queue during

skill-card.md

## Description:

Provides patterns and JavaScript helpers for building multi-step agent workflows with checkpoints, retries, timeouts, dead letter handling, alerting, and single-instance locks.

This skill is ready for commercial/non-commercial use.

## Publisher:

[old-greggyboy](https://clawhub.ai/user/old-greggyboy)

### License/Terms of Use:

MIT-0

## Use Case:

Developers and engineers use this skill to design resilient automations, pipelines, and agent loops that can resume after failures, avoid duplicate work, and surface failed items for review.

### Deployment Geography for Use:

Global

## Known Risks and Mitigations:

Risk: Bundled workflow scripts include file-locking and temporary-file weaknesses that may matter for business-critical or non-idempotent workflows.

Mitigation: Review and harden lock and temporary-file creation before deployment, and keep state and lock files in a private directory.

Risk: Workflow state, dead letter, and lock files can expose operational data if stored in shared or predictable locations.

Mitigation: Configure state, dead letter, and lock paths to private directories with restrictive permissions.

Risk: Failure alerts can expose raw exception details to Telegram or another external alert channel.

Mitigation: Sanitize alert messages and avoid sending secrets, raw exception text, or sensitive workflow data to external channels.

## Reference(s):

- [Agent Workflow Failure Taxonomy](references/failure-taxonomy.md)
- [ClawHub skill page](https://clawhub.ai/old-greggyboy/skills/durable-workflow)
- [ClawHub publisher profile](https://clawhub.ai/user/old-greggyboy)

## Skill Output:

**Output Type(s):** [guidance, code, shell commands, configuration]

**Output Format:** [Markdown guidance with JavaScript and shell code blocks]

**Output Parameters:** [1D]

**Other Properties Related to Output:** [Includes reusable workflow and lock scripts for adaptation by the agent.]

## Skill Version(s):

1.0.1 (source: server release evidence)

## Ethical Considerations:

Users should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.

Sponsored

Ads related to Durable Workflow and adjacent AI workflows.