error-recovery
Handle errors, timeouts, and failures in multi-agent workflows. Use when dealing with external model timeouts, API failures, partial success, user cancellation, or graceful degradation. Trigger keywords - "error", "failure", "timeout", "retry", "fallback", "cancelled", "graceful degradation", "recovery", "partial success".
What this skill does
# Error Recovery
**Version:** 1.0.0
**Purpose:** Patterns for handling failures in multi-agent workflows
**Status:** Production Ready
## Overview
Error recovery is the practice of handling failures gracefully in multi-agent workflows, ensuring that temporary errors, timeouts, or partial failures don't derail entire workflows. In production systems with external dependencies (AI models, APIs, network calls), failures are inevitable. The question is not "will it fail?" but "how will we handle it when it does?"
This skill provides battle-tested patterns for:
- **Timeout handling** (external models taking >30s)
- **API failure recovery** (401, 500, network errors)
- **Partial success strategies** (some agents succeed, others fail)
- **User cancellation** (graceful Ctrl+C handling)
- **Missing tools** (claudish not installed)
- **Out of credits** (payment/quota errors)
- **Retry strategies** (exponential backoff, max retries)
With proper error recovery, workflows become **resilient** and **production-ready**.
## Core Patterns
### Pattern 1: Timeout Handling
**Scenario: External Model Takes >30s**
External AI models via Claudish may take >30s due to:
- Model service overloaded (high demand)
- Network latency (slow connection)
- Complex task (large input, detailed analysis)
- Model thinking time (GPT-5, Grok reasoning models)
**Detection:**
```
Monitor execution time and set timeout limits:
const TIMEOUT_THRESHOLD = 30000; // 30 seconds
startTime = Date.now();
executeClaudish(model, prompt);
setInterval(() => {
elapsedTime = Date.now() - startTime;
if (elapsedTime > TIMEOUT_THRESHOLD && !modelResponded) {
handleTimeout();
}
}, 1000);
```
**Recovery Strategy:**
```
Step 1: Detect Timeout
Log: "Timeout: x-ai/grok-code-fast-1 after 30s with no response"
Step 2: Notify User
Present options:
"Model 'Grok' timed out after 30 seconds.
Options:
1. Retry with 60s timeout
2. Skip this model and continue with others
3. Cancel entire workflow
What would you like to do? (1/2/3)"
Step 3a: User selects RETRY
Increase timeout to 60s
Re-execute claudish with longer timeout
If still times out: Offer skip or cancel
Step 3b: User selects SKIP
Log: "Skipping Grok review due to timeout"
Mark this model as failed
Continue with remaining models
(Graceful degradation pattern)
Step 3c: User selects CANCEL
Exit workflow gracefully
Save partial results (if any)
Log cancellation reason
```
**Graceful Degradation:**
```
Multi-Model Review Example:
Requested: 5 models (Claude, Grok, Gemini, GPT-5, DeepSeek)
Timeout: Grok after 30s
Result:
- Claude: Success ✓
- Grok: Timeout ✗ (skipped)
- Gemini: Success ✓
- GPT-5: Success ✓
- DeepSeek: Success ✓
Successful: 4/5 models (80%)
Threshold: N ≥ 2 for consolidation ✓
Action:
Proceed with consolidation using 4 reviews
Notify user: "4/5 models completed (Grok timeout). Proceeding with 4-model consensus."
Benefits:
- Workflow completes despite failure
- User gets results (4 models better than 1)
- Timeout doesn't derail entire workflow
```
**Example Implementation:**
```bash
# In codex-code-reviewer agent (proxy mode)
MODEL="x-ai/grok-code-fast-1"
TIMEOUT=30
# Execute with timeout
RESULT=$(timeout ${TIMEOUT}s bash -c "
printf '%s' '$PROMPT' | claudish --model $MODEL --stdin --quiet --auto-approve
" 2>&1)
# Check exit code
if [ $? -eq 124 ]; then
# Timeout occurred (exit code 124 from timeout command)
echo "⚠️ Timeout: Model $MODEL exceeded ${TIMEOUT}s" >&2
echo "TIMEOUT_ERROR: Model did not respond within ${TIMEOUT}s"
exit 1
fi
# Success - write results
echo "$RESULT" > ai-docs/grok-review.md
echo "Grok review complete. See ai-docs/grok-review.md"
```
---
### Pattern 2: API Failure Recovery
**Common API Failure Scenarios:**
```
401 Unauthorized:
- Invalid API key (OPENROUTER_API_KEY incorrect)
- Expired API key
- API key not set in environment
500 Internal Server Error:
- Model service temporarily down
- Server overload
- Model deployment issue
Network Errors:
- Connection timeout (network slow/unstable)
- DNS resolution failure
- Firewall blocking request
429 Too Many Requests:
- Rate limit exceeded
- Too many concurrent requests
- Quota exhausted for time window
```
**Recovery Strategies by Error Type:**
**401 Unauthorized:**
```
Detection:
API returns 401 status code
Recovery:
1. Log: "API authentication failed (401)"
2. Check if OPENROUTER_API_KEY is set:
if [ -z "$OPENROUTER_API_KEY" ]; then
notifyUser("OpenRouter API key not found. Set OPENROUTER_API_KEY in .env")
else
notifyUser("Invalid OpenRouter API key. Check .env file")
fi
3. Skip all external models
4. Fallback to embedded Claude only
5. Notify user:
"⚠️ API authentication failed. Falling back to embedded Claude.
To fix: Add valid OPENROUTER_API_KEY to .env file."
No retry (authentication won't fix itself)
```
**500 Internal Server Error:**
```
Detection:
API returns 500 status code
Recovery:
1. Log: "Model service error (500): x-ai/grok-code-fast-1"
2. Wait 5 seconds (give service time to recover)
3. Retry ONCE
4. If retry succeeds: Continue normally
5. If retry fails: Skip this model, continue with others
Example:
try {
result = await claudish(model, prompt);
} catch (error) {
if (error.status === 500) {
log("500 error, waiting 5s before retry...");
await sleep(5000);
try {
result = await claudish(model, prompt); // Retry
log("Retry succeeded");
} catch (retryError) {
log("Retry failed, skipping model");
skipModel(model);
continueWithRemaining();
}
}
}
Max retries: 1 (avoid long delays)
```
**Network Errors:**
```
Detection:
- Connection timeout
- ECONNREFUSED
- ETIMEDOUT
- DNS resolution failure
Recovery:
Retry up to 3 times with exponential backoff:
async function retryWithBackoff(fn, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
return await fn();
} catch (error) {
if (!isNetworkError(error)) throw error; // Not retriable
if (i === maxRetries - 1) throw error; // Max retries reached
const delay = Math.pow(2, i) * 1000; // 1s, 2s, 4s
log(`Network error, retrying in ${delay}ms (attempt ${i+1}/${maxRetries})`);
await sleep(delay);
}
}
}
result = await retryWithBackoff(() => claudish(model, prompt));
Rationale: Network errors are often transient (temporary)
```
**429 Rate Limiting:**
```
Detection:
API returns 429 status code
Response may include Retry-After header
Recovery:
1. Check Retry-After header (seconds to wait)
2. If present: Wait for specified time
3. If not present: Wait 60s (default)
4. Retry ONCE after waiting
5. If still rate limited: Skip model
Example:
if (error.status === 429) {
const retryAfter = error.headers['retry-after'] || 60;
log(`Rate limited. Waiting ${retryAfter}s before retry...`);
await sleep(retryAfter * 1000);
try {
result = await claudish(model, prompt);
} catch (retryError) {
log("Still rate limited after retry. Skipping model.");
skipModel(model);
}
}
Note: Respect Retry-After header (avoid hammering API)
```
**Graceful Degradation for All API Failures:**
```
Fallback Strategy:
If ALL external models fail (401, 500, network, etc.):
1. Log all failures
2. Notify user:
"⚠️ All external models failed. Falling back to embedded Claude.
Errors:
- Grok: Network timeout
- Gemini: 500 Internal Server Error
- GPT-5: Rate limited (429)
- DeepSeek: Authentication failed (401)
Proceeding with Claude Sonnet (embedded) only."
3. Run embedded Claude review
4. Present results with disclaimer:
"Review completed using Claude only (external models unavailable).
For multi-model consensus, try again later."
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.