Class: Aidp::Harness::ErrorHandler::RecoveryPlanner

Inherits:
Object
  • Object
show all
Defined in:
lib/aidp/harness/error_handler.rb

Instance Method Summary collapse

Instance Method Details

#create_recovery_plan(error_info, _context = {}) ⇒ Object



660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
# File 'lib/aidp/harness/error_handler.rb', line 660

def create_recovery_plan(error_info, _context = {})
  error_type = error_info[:error_type]

  # Use ErrorTaxonomy to determine recovery strategy
  case error_type
  when :rate_limited
    {
      action: :switch_provider,
      reason: "Rate limit reached, switching provider",
      priority: :high
    }
  when :auth_expired
    # Try to switch to another provider. If no providers available, this will
    # be detected in attempt_recovery and we'll crash (crash-early principle)
    {
      action: :switch_provider,
      reason: "Authentication expired – switching provider to continue",
      priority: :critical,
      crash_if_no_fallback: true
    }
  when :quota_exceeded
    {
      action: :switch_provider,
      reason: "Quota exceeded, switching provider",
      priority: :high
    }
  when :transient
    {
      action: :switch_model,
      reason: "Transient error, trying alternate model",
      priority: :medium
    }
  when :permanent
    {
      action: :escalate,
      reason: "Permanent error, requires manual intervention",
      priority: :critical
    }
  else
    {
      action: :switch_provider,
      reason: "Unknown error, attempting provider switch",
      priority: :low
    }
  end
end