← Back to Skills Marketplace
hanxiao-bot

Error Recovery

by hanxiao-bot · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ Security Clean
193
Downloads
0
Stars
2
Active Installs
1
Versions
Install in OpenClaw
/install error-recovery
Description
Error Recovery - Strategies for handling failures gracefully
README (SKILL.md)

Error Recovery - Handling Failures Gracefully

OpenClaw Error Types

Error Cause Recovery
429 Rate Limit Too many requests Wait + retry with backoff
402 Billing API credits exhausted Switch model or wait
503 Overloaded Provider busy Wait + retry
Context Overflow Context window full Trigger compaction
Role Ordering Corrupted session Reset session
Transient HTTP Network issue Auto-retry (built-in)

Error Handling Patterns

Pattern 1: Retry with Backoff

async function retryWithBackoff(fn, maxAttempts = 3) {
  for (let i = 0; i \x3C maxAttempts; i++) {
    try {
      return await fn();
    } catch (err) {
      if (isRetryable(err) && i \x3C 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

Mechanism Trigger Action
Auto-retry 408/429/5xx Exponential backoff
Context overflow Token limit Trigger compaction
Session corruption Role error Reset session
Model switch persistent failure Fallback 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
Usage Guidance
This is a documentation-style skill containing example patterns for error handling; it appears coherent and low-risk. Before installing, confirm your agent/platform actually uses MEMORY.md and that you don't store secrets there (the guidance to 'keep MEMORY.md updated' could encourage persistent storage). Also treat the code snippets as examples — verify they fit your runtime and logging policies so error logs don't leak sensitive data.
Capability Analysis
Type: OpenClaw Skill Name: error-recovery Version: 1.0.0 The skill bundle consists of educational documentation and standard JavaScript code patterns (retry with backoff, circuit breaker, and fallback mechanisms) for handling API and session errors. There are no executable scripts, suspicious network calls, or prompt-injection attempts in SKILL.md.
Capability Assessment
Purpose & Capability
Name/description (Error Recovery) match the SKILL.md content: retry/backoff, graceful degradation, circuit breaker, session recovery and best practices. No unrelated credentials, binaries, or config paths are requested.
Instruction Scope
Runtime instructions are code examples and prose for handling errors within an agent. They reference agent concepts (MEMORY.md, agent-runner) in a way consistent with recovery behavior and do not instruct reading arbitrary system files or exfiltrating data.
Install Mechanism
There is no install spec and no code files — this is instruction-only, so nothing is written to disk or downloaded.
Credentials
The skill declares no environment variables, credentials, or config paths. The small references to MEMORY.md are reasonable for session recovery guidance but do not imply credential access.
Persistence & Privilege
always is false and disable-model-invocation is default (agent may invoke autonomously). The skill does not request persistent presence or modify other skills or system-wide settings.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install error-recovery
  3. After installation, invoke the skill by name or use /error-recovery
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
- Initial release of the error-recovery skill. - Documents common OpenClaw error types and recommended recovery strategies. - Provides JavaScript code patterns for retry with backoff, graceful degradation, and circuit breaker. - Details tool failure handling and session corruption recovery processes. - Outlines built-in recovery mechanisms and best practices for resilient error handling.
Metadata
Slug error-recovery
Version 1.0.0
License MIT-0
All-time Installs 2
Active Installs 2
Total Versions 1
Frequently Asked Questions

What is Error Recovery?

Error Recovery - Strategies for handling failures gracefully. It is an AI Agent Skill for Claude Code / OpenClaw, with 193 downloads so far.

How do I install Error Recovery?

Run "/install error-recovery" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Error Recovery free?

Yes, Error Recovery is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Error Recovery support?

Error Recovery is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Error Recovery?

It is built and maintained by hanxiao-bot (@hanxiao-bot); the current version is v1.0.0.

💬 Comments