Claw Mart
← All issuesClaw Mart Daily
Issue #208July 22, 2026

Build your agent a recovery ladder before it needs rescue

Your agent hits a wall. Maybe it's an API timeout. Maybe it's a file permission error. Maybe it's a network hiccup. What happens next determines whether you have a production system or an expensive toy.

Most agents just... stop. They report the error and wait for you to fix it. But the best agents I've built have something different: a recovery ladder.

Here's the pattern that changed everything for me:

RECOVERY_LADDER = {
  "api_timeout": [
    "retry_with_backoff",
    "try_alternate_endpoint", 
    "degrade_to_cached_response",
    "escalate_to_human"
  ],
  "file_permission_denied": [
    "request_elevated_permissions",
    "try_alternate_location",
    "create_temporary_workaround",
    "escalate_to_human"
  ],
  "rate_limit_exceeded": [
    "wait_and_retry",
    "switch_to_backup_api_key",
    "queue_for_later_execution",
    "escalate_to_human"
  ]
}

The magic isn't in the specific steps—it's in having graduated responses instead of binary success/failure.

I learned this the hard way when my coding agent kept dying on GitHub API rate limits. Instead of just failing and reporting "rate limited," it now:

  • Waits for the reset window (if under 10 minutes)
  • Switches to a backup token (if available)
  • Queues the operation for later (if not urgent)
  • Only escalates if all else fails

The result? My agent went from needing intervention 3-4 times a day to maybe once a week.

Pro tip: Build your recovery ladder before you hit production. I spent two weeks retrofitting this pattern after my agent started handling real work. Much easier to design resilience upfront.

The key insight: most "failures" are actually temporary obstacles. Your agent should exhaust reasonable recovery options before bothering you.

Here's how I implement it:

def handle_error(error_type, context, attempt=1):
    recovery_steps = RECOVERY_LADDER.get(error_type, ["escalate_to_human"])
    
    if attempt > len(recovery_steps):
        return escalate_to_human(error_type, context)
    
    current_step = recovery_steps[attempt - 1]
    
    try:
        result = execute_recovery_step(current_step, context)
        if result.success:
            log_recovery(error_type, current_step, attempt)
            return result
    except Exception as recovery_error:
        log_recovery_failure(current_step, recovery_error)
    
    # Try next step in ladder
    return handle_error(error_type, context, attempt + 1)

This isn't just error handling—it's operational resilience. Your agent becomes antifragile instead of brittle.

The best part? You can tune the ladder based on what actually breaks. My file permission ladder used to have 5 steps. Turns out step 2 ("try alternate location") solved 80% of cases, so I optimized around that.

Your agent should be more persistent than you are. Build it a ladder to climb out of holes, and it'll surprise you how rarely it needs rescue.

Paste into your agent's workspace

Claw Mart Daily

Get tips like this every morning

One actionable AI agent tip, delivered free to your inbox every day.