Main Site โ†—

error-recovery

by marcusgoll746GitHub

Classify workflow failures and attempt automatic recovery. Use when sprint/feature fails during implementation to determine if auto-fix is possible or manual intervention required.

Unlock Deep Analysis

Use AI to visualize the workflow and generate a realistic output preview for this skill.

Powered by Fastest LLM

Target Audience

Developers and DevOps engineers managing automated CI/CD pipelines who need to reduce manual intervention for transient failures

8/10Security

Low security risk, safe to use

9
Clarity
8
Practicality
7
Quality
6
Maintainability
7
Innovation
Development
Compatible Agents
Claude Code
Claude Code
~/.claude/skills/
Codex CLI
Codex CLI
~/.codex/skills/
Gemini CLI
Gemini CLI
~/.gemini/skills/
O
OpenCode
~/.opencode/skills/
O
OpenClaw
~/.openclaw/skills/
GitHub Copilot
GitHub Copilot
~/.copilot/skills/
Cursor
Cursor
~/.cursor/skills/
W
Windsurf
~/.codeium/windsurf/skills/
C
Cline
~/.cline/skills/
R
Roo Code
~/.roo/skills/
K
Kiro
~/.kiro/skills/
J
Junie
~/.junie/skills/
A
Augment Code
~/.augment/skills/
W
Warp
~/.warp/skills/
G
Goose
~/.config/goose/skills/
SKILL.md

Error Recovery - Handling Failures Gracefully

OpenClaw Error Types

ErrorCauseRecovery
429 Rate LimitToo many requestsWait + retry with backoff
402 BillingAPI credits exhaustedSwitch model or wait
503 OverloadedProvider busyWait + retry
Context OverflowContext window fullTrigger compaction
Role OrderingCorrupted sessionReset session
Transient HTTPNetwork issueAuto-retry (built-in)

Error Handling Patterns

Pattern 1: Retry with Backoff

async function retryWithBackoff(fn, maxAttempts = 3) {
  for (let i = 0; i < maxAttempts; i++) {
    try {
      return await fn();
    } catch (err) {
      if (isRetryable(err) && i < maxAttempts - 1) {
        await sleep(1000 * Math.pow(2, i)); // 1s, 2s, 4s
        continue;
      }
      throw err;
    }
  }
}

Pattern 2: Graceful Degradation

async function withFallback(primary, fallback) {
  try {
    return await primary();
  } catch (err) {
    console.warn("Primary failed, trying fallback:", err.message);
    return await fallback();
  }
}

// Usage
const result = await withFallback(
  () => callExpensiveModel(msg),
  () => callCheapModel(msg)
);

Pattern 3: Circuit Breaker

class CircuitBreaker {
  constructor(fn, threshold = 3) {
    this.fn = fn;
    this.failures = 0;
    this.threshold = threshold;
    this.state = "closed"; // open/closed/half-open
  }

  async execute() {
    if (this.state === "open") {
      throw new Error("Circuit breaker open");
    }
    try {
      const result = await this.fn();
      this.failures = 0;
      this.state = "closed";
      return result;
    } catch (err) {
      this.failures++;
      if (this.failures >= this.threshold) {
        this.state = "open";
      }
      throw err;
    }
  }
}

Tool Failure Handling

Tools in OpenClaw are non-fatal โ€” if a tool fails, the agent continues:

// In agent-runner, tool errors are caught but don't stop execution
.catch((err) => {
  log(`Tool ${toolName} failed: ${err.message}`);
  // Continue execution
});

Session Corruption Recovery

If session becomes corrupted:

  1. Detection: Role ordering errors, malformed messages
  2. Action: Session auto-reset by OpenClaw
  3. Recovery: Fresh session, context preserved via MEMORY.md

Built-in Recovery Mechanisms

MechanismTriggerAction
Auto-retry408/429/5xxExponential backoff
Context overflowToken limitTrigger compaction
Session corruptionRole errorReset session
Model switchpersistent failureFallback model

Best Practices

  1. Don't suppress errors silently โ€” log them
  2. Prefer retries for transient failures โ€” network/timeout
  3. Reset for corruption โ€” don't try to fix corrupted state
  4. Use fallback models โ€” cheap โ†’ expensive
  5. Keep MEMORY.md updated โ€” for recovery after reset

Source: https://github.com/marcusgoll/Spec-Flow#.claude-skills-error-recovery

Content curated from original sources, copyright belongs to authors

Grade A
7.5AI Score
Best Practices
Checking...
Try this Skill

User Rating

USER RATING

0UP
0DOWN
Loading files...

WORKS WITH

Claude Code
Claude
Codex CLI
Codex
Gemini CLI
Gemini
O
OpenCode
O
OpenClaw
GitHub Copilot
Copilot
Cursor
Cursor
W
Windsurf
C
Cline
R
Roo
K
Kiro
J
Junie
A
Augment
W
Warp
G
Goose