Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:0x4m4 Hexstrike ai Resilient Subprocess Execution

From Leeroopedia
Knowledge Sources
Domains Subprocess, Reliability, Tool_Execution
Last Updated 2026-10-10 00:00 GMT

Overview

Execution pattern that wraps subprocess calls in a recovery loop with error detection, strategy selection, and multiple recovery actions (retry, parameter adjustment, tool switching, graceful degradation).

Description

The Resilient Subprocess Execution principle describes a wrapper around subprocess execution that treats failures as recoverable events rather than terminal errors. On each failure, the system classifies the error, selects a recovery strategy, and applies it before retrying. Recovery strategies include exponential backoff, scope reduction, parameter adjustment, alternative tool switching, graceful degradation, human escalation, and abort. The system tracks a full recovery history for debugging and escalation context.

Usage

Apply this principle when executing external commands that may fail transiently:

  • Long-running scans: Tools like nmap and sqlmap may timeout or hit rate limits
  • Unattended execution: Recovery allows scans to continue without human intervention
  • Production reliability: Multiple recovery strategies prevent single-point failures from aborting entire pipelines

Theoretical Basis

The recovery loop follows a classify-act-retry cycle:

# Abstract pattern (NOT real implementation)
for attempt in range(max_attempts):
    result = execute(command)
    if result.success:
        return result

    error_type = classify(result.stderr)
    strategy = select_strategy(error_type, attempt_count)

    if strategy.action == RETRY_WITH_BACKOFF:
        sleep(backoff_delay(attempt))
    elif strategy.action == ADJUST_PARAMETERS:
        command = rebuild_with_params(adjusted_params)
    elif strategy.action == SWITCH_TOOL:
        return suggest_alternative(strategy.alternative)
    elif strategy.action == ESCALATE:
        return escalate_to_human(context)

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment