Parallel skill runner

From paulpas/agent-skill-router · View interactive version

Parallel skill runner is an AI agent skill from the GitHub repository paulpas/agent-skill-router. Implements intelligent parallel skill runner with multi-factor skill selection, fallback chains, and adherence to the 5 Laws of Elegant Defense

How to use this skill

Skill file

Parallel Skill Runner

Orchestrates intelligent skill selection and execution for parallel skill runner workflows. Applies the 5 Laws of Elegant Defense to guide data naturally through the orchestration pipeline, preventing errors before they occur. Selects optimal skills based on multi-factor scoring including text similarity, historical performance, and system availability.

TL;DR Checklist

┌───────────────────────────────────────────────────────────────────────────────┐

│ Orchestration Flow │

└───────────────────────────────────────────────────────────────────────────────┘

User Request

↓

┌─────────────────┐

│ Parse Request │

│ & Extract │

│ Features │

└────────┬────────┘

↓

┌─────────────────────────────────────────────────────────────────────┐

│ Evaluate Available Skills │

│ │

│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │

│ │ Skill A │ │ Skill B │ │ Skill C │ │

│ │ - Match Score│ │ - Match Score│ │ - Match Score│ │

│ │ - Confidence │ │ - Confidence │ │ - Confidence │ │

│ │ - History │ │ - History │ │ - History │ │

│ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │

│ │ │ │ │

│ └─────────────────┴─────────────────┘ │

│ ↓ │

│ Select Best Skill │

└─────────────────────────────────────────────────────────────────────┘

↓

┌─────────────────┐

│ Execute Skill │

└────────┬────────┘

↓

┌─────────────────┐

│ Handle Result │

└────────┬────────┘

↓

┌─────────────────────────────────────────────────────────────────────┐

│ Error Handling & Fallback │

│ │

│ Success? ────────► Return Result │

│ │

│ Fail? ────────┐ │

│ ↓ │

│ ┌──────────────────────────────────────────────────────────┐ │

│ │ Fallback Chain │ │

│ │ │ │

│ │ 1. Retry with adjusted parameters │ │

│ │ 2. Try Alternative Skill (if available) │ │

│ │ 3. Defer to Human Operator (if critical) │ │

│ │ 4. Log & Return Error │ │

│ └──────────────────────────────────────────────────────────┘ │

└─────────────────────────────────────────────────────────────────────┘

When to Use

Use this skill when:

When NOT to Use

Avoid this skill for:

Core Workflow

  1. Parse and Analyze Request - Extract intent, entities, and constraints from user input.

Checkpoint: All required parameters must be present and in valid format before proceeding.

  1. Score Available Skills - Calculate match scores using multi-factor algorithm:

Checkpoint: Skip to fallback if no skill scores above threshold.

  1. Select Optimal Skill - Choose skill with highest score that meets minimum confidence.

Checkpoint: Verify skill has not been disabled or deprecated.

  1. Execute with Fallback - Run skill execution wrapped in retry and fallback logic.

Checkpoint: Log all execution attempts for audit trail.

  1. Return or Fallback - Either return successful result or apply fallback chain:

Checkpoint: Record outcome with timing and confidence metadata.

Implementation Patterns

Pattern 1: Skill Selection Logic

def evaluate_parallel_candidates(
    task: str,
    candidate_skills: List[SkillMetadata],
    historical_registry: Dict[str, HistoricalRecord]
) -> List[RankedSkill]:
    """Score and rank skills for parallel dispatch based on multi-factor metrics.
    
    Applies Law 2 (Parse at boundary) by validating inputs upfront.
    Returns immutable ranked list for deterministic routing.
    """
    if not task or not candidate_skills:
        raise ValueError("Task and candidate_skills must be non-empty")
        
    parsed_task = _parse_intent_and_entities(task)
    ranked = []
    
    for skill in candidate_skills:
        if not _is_skill_available(skill):
            continue
            
        text_match = _cosine_similarity(parsed_task.terms, skill.trigger_terms)
        history = historical_registry.get(skill.id, HistoricalRecord())
        success_rate = history.success_count / max(history.total_runs, 1)
        availability_score = _get_current_load_score(skill.endpoint)
        
        composite_score = (0.4 * text_match) + (0.4 * success_rate) + (0.2 * availability_score)
        
        ranked.append(RankedSkill(
            skill=skill,
            confidence=composite_score,
            expected_latency_ms=_estimate_latency(skill, parsed_task)
        ))
        
    ranked.sort(key=lambda x: x.confidence, reverse=True)
    return ranked

Pattern 2: Execution with Fallback

async def run_parallel_with_fallback(
    ranked_skills: List[RankedSkill],
    task_context: Dict,
    fallback_map: Dict[str, List[str]],
    timeout_seconds: float = 30.0
) -> ParallelExecutionResult:
    """Execute top N skills in parallel with per-skill fallback chains.
    
    Implements Law 4 (Fail Fast/Loud) by isolating failures and applying fallbacks.
    Returns aggregated results without mutating original context.
    """
    if not ranked_skills:
        raise ParallelExecutionError("No skills available for parallel execution")
        
    selected = ranked_skills[:3] # Execute top 3 in parallel
    tasks = []
    
    for ranked in selected:
        tasks.append(_execute_single_skill_with_fallback(
            skill=ranked.skill,
            context=task_context,
            fallback_chain=fallback_map.get(ranked.skill.id, []),
            timeout=timeout_seconds
        ))
        
    results = await asyncio.gather(*tasks, return_exceptions=True)
    
    aggregated = ParallelExecutionResult(
        success_count=0,
        failed_count=0,
        results=[],
        fallbacks_triggered=[]
    )
    
    for ranked, result in zip(selected, results):
        if isinstance(result, Exception):
            aggregated.failed_count += 1
            aggregated.fallbacks_triggered.append(ranked.skill.id)
        else:
            aggregated.success_count += 1
            aggregated.results.append(result)
            
    return aggregated

MUST DO

MUST NOT DO

TL;DR Checklist

TL;DR for Code Generation

Output Template

When applying this skill, produce:

  1. Selected Skills - List of skill names with confidence scores
  2. Selection Rationale - Why each skill was chosen (match score, history, availability)
  3. Execution Plan - Order of execution with dependencies
  4. Fallback Strategy - Which fallback skills will be tried and in what order
  5. Risk Assessment - Any potential failure points and their impact
  6. Timing Estimates - Expected latency including fallback scenarios

Related Skills

| Skill | Purpose |

|---|---|

| agent-confidence-based-selector | Provides the confidence-based selection layer that this parallel runner orchestrates across multiple candidates |

| agent-task-routing | Handles sequential task routing — use this when tasks must be ordered rather than parallelized |


Constraints

MUST DO

MUST NOT DO

Live References

Authoritative documentation links for this skill's domain. The model follows markdown links at load time to resolve external references and inline content.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.