| name | error-recovery-patterns |
| description | Document common error types, provide recovery strategies, retry patterns with limits, and fallback strategies. Use when encountering compilation errors, test failures, tool failures, or other execution errors. Provides systematic approach to error handling and recovery. |
Error Recovery Patterns
Overview
Systematic approach to handling and recovering from common errors during task execution. Provides recovery strategies, retry patterns, and fallback approaches for different error types.
Common Error Types
1. Compilation Errors
Symptoms:
- TypeScript compilation fails
- Syntax errors (missing braces, semicolons)
- Type mismatches
- Import path errors
- Method name mismatches
Recovery Strategy:
- Read error message carefully: Understand what's wrong
- Fix syntax/type errors immediately: Don't proceed with broken code
- Re-run compilation check:
npx tsc --noEmit
- If errors persist: Check for missing imports or type definitions
Common Patterns:
- Syntax errors: Check for missing/extra braces, parentheses, semicolons
- Type mismatches: Verify interface compatibility, check actual types
- Import errors: Use relative paths, check file existence
- Method name mismatches: Check actual method names in source code
When to skip: Never skip compilation errors - must fix before proceeding
2. Test Failures
Symptoms:
- Tests fail with assertion errors
- Tests timeout
- Tests are flaky (pass/fail intermittently)
- Test setup/teardown fails
Recovery Strategy:
- Read test output: Understand what failed and why
- Classify failure: Is test flaky or code broken?
- Fix code if broken: Update implementation to match test expectations
- Skip test if flaky: Document why test was skipped
- Re-run tests: Verify fix or skip
Common Patterns:
- Assertion failures: Code doesn't match test expectations
- Timeouts: Test takes too long (increase timeout or optimize code)
- Flaky tests: Non-deterministic behavior (seed RNG, fix timing)
- Setup failures: Test environment not configured correctly
When to skip: Only skip if test is flaky and not critical for task
3. Tool Failures
Symptoms:
- API errors (401, 403, 500)
- Network timeouts
- Invalid credentials
- Tool unavailable
- Rate limiting
Recovery Strategy:
- Check error message: Understand root cause
- If API key missing/invalid: Skip tool usage (don't retry)
- If network timeout: Retry with exponential backoff (max 3 times)
- If tool unavailable: Use alternative approach
- Document fallback: Explain why alternative was used
Common Patterns:
- API errors: Check credentials, verify API key, check rate limits
- Network timeouts: Retry with delays, check network connectivity
- Tool unavailable: Service down, use alternative tool
- Rate limiting: Wait and retry, or use alternative approach
When to skip: Skip if tool consistently failing or not critical
4. Browser Testing Failures
Symptoms:
- Browser commands timeout
- Elements not found
- Test seam unavailable
- Scene navigation fails
Recovery Strategy:
- Check timeout: Increase timeout or use polling
- Verify element exists: Check DOM, wait for element
- Check test seam: Verify
window.__TEST__ is available
- Use fallback: Console logs, screenshots, code review
Common Patterns:
- Timeouts: Increase timeout, use polling instead of fixed wait
- Element not found: Wait for element, check selector
- Test seam unavailable: Check scene initialization, wait for ready
- Navigation fails: Verify scene key, check scene registration
When to skip: Skip if browser testing not critical, use code review instead
Retry Patterns with Limits
Exponential Backoff
Pattern:
- First retry: 1 second delay
- Second retry: 2 second delay
- Third retry: 4 second delay
- After 3 retries: Skip and use alternative
When to use:
- Transient failures (timeouts, network issues)
- Likely to succeed on retry
- No alternative available
When NOT to use:
- API key errors (won't succeed on retry)
- Tool unavailable (service down)
- Invalid credentials (won't succeed on retry)
Retry Limits
Maximum retries: 3 attempts
After 3 retries:
- Skip tool/step
- Use alternative approach
- Document why skipped
Fallback Strategies
Strategy 1: Use Alternative Tool
When primary tool fails:
- Use different tool with same functionality
- Example:
agent-browser fails → use code review + compilation check
Pattern:
- Identify alternative tool
- Try alternative
- If alternative works, continue
- If alternative fails, try next fallback
Strategy 2: Graceful Degradation
When cost-incurring tool fails:
- Use free alternative
- Example: ElevenLabs TTS fails → use console.log for verification
Pattern:
- Check if free alternative exists
- Use free alternative
- Document why alternative was used
Strategy 3: Skip Non-Critical Steps
When step is not critical:
- Skip step and continue
- Document why skipped
- Example: Visual verification skipped → use code review
Pattern:
- Verify step is not critical
- Skip step
- Document why skipped
- Continue with remaining steps
Strategy 4: Code Review + Compilation Check
When browser testing fails:
- Use code review to verify implementation
- Run TypeScript compilation check
- Verify logic matches requirements
Pattern:
- Review code changes
- Run
npx tsc --noEmit
- Verify logic matches requirements
- Document verification method
Error Classification
Critical Errors (Must Fix)
- Compilation errors: Code won't run
- Type errors: Type safety violated
- Syntax errors: Code invalid
Action: Fix immediately, don't proceed
Non-Critical Errors (Can Skip)
- Visual verification: Can use code review
- Optional features: Not required for task
- Cost-incurring tools: Can use free alternatives
Action: Skip if alternative available
Transient Errors (Retry)
- Network timeouts: Likely to succeed on retry
- Rate limiting: Wait and retry
- Temporary service issues: Retry with backoff
Action: Retry with exponential backoff (max 3 times)
Recovery Workflow
Step 1: Classify Error
- Read error message: Understand what failed
- Identify error type: Compilation, test, tool, browser
- Determine severity: Critical, non-critical, transient
Step 2: Choose Recovery Strategy
- Critical errors: Fix immediately
- Non-critical errors: Skip if alternative available
- Transient errors: Retry with backoff
Step 3: Execute Recovery
- Fix errors: Update code, fix syntax, correct types
- Retry with backoff: Wait and retry (max 3 times)
- Use alternative: Switch to different tool/approach
- Skip step: Document why skipped
Step 4: Verify Recovery
- Re-run checks: Compilation, tests, verification
- Verify fix: Confirm error is resolved
- Document recovery: Explain what was done
Best Practices
- Fix errors immediately: Don't accumulate errors
- Use retries wisely: Only for transient failures
- Have fallback strategies: Always know alternative approach
- Document recoveries: Explain why alternative was used
- Don't retry forever: Set limits (max 3 retries)
Resources
agent-workflow-guidelines skill - General workflow guidelines
loop-detection-prevention skill - Prevent infinite retry loops
typescript-incremental-check skill - TypeScript error patterns