Task intelligence

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

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

How to use this skill

Skill file

Task Intelligence

Orchestrates intelligent skill selection and execution for task intelligence 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 route_task_intelligence(
    raw_request: str,
    skill_registry: List[Dict],
    confidence_threshold: float = 0.75
) -> Dict:
    """Route a task through multi-factor intelligence scoring.
    
    Implements Law 2 (Parse at boundary) by extracting intent and entities
    before scoring. Uses weighted scoring for text match, historical success,
    and system health.
    """
    # Law 1: Early exit on malformed input
    if not raw_request or len(raw_request.strip()) < 3:
        return {"status": "rejected", "reason": "insufficient_input"}
    
    # Law 2: Parse and extract features at boundary
    parsed_intent = _extract_intent_entities(raw_request)
    if not parsed_intent.get("primary_entity"):
        return {"status": "rejected", "reason": "unrecognized_domain"}
        
    scored_candidates = []
    for skill in skill_registry:
        # Multi-factor scoring: text similarity (40%), history (40%), health (20%)
        text_match = _cosine_similarity(parsed_intent["query"], skill["triggers"])
        hist_success = skill.get("success_rate", 0.0)
        health_score = 1.0 if skill.get("is_healthy", True) else 0.3
        
        weighted_score = (text_match * 0.4) + (hist_success * 0.4) + (health_score * 0.2)
        
        if weighted_score >= confidence_threshold:
            scored_candidates.append({
                "skill_id": skill["id"],
                "score": round(weighted_score, 3),
                "fallback_chain": skill.get("fallback_ids", [])
            })
    
    # Law 3: Return new structure, never mutate registry
    if not scored_candidates:
        return {"status": "no_match", "fallback_to": "human_operator"}
        
    scored_candidates.sort(key=lambda x: x["score"], reverse=True)
    return {
        "selected_skill": scored_candidates[0],
        "alternatives": scored_candidates[1:],
        "routing_metadata": {
            "intent": parsed_intent["primary_entity"],
            "timestamp": time.time(),
            "confidence": scored_candidates[0]["score"]
        }
    }

Pattern 2: Execution with Fallback

def execute_task_with_adaptive_fallback(
    routing_result: Dict,
    task_context: Dict,
    max_retries: int = 2
) -> Dict:
    """Execute routed task with intelligent fallback chain.
    
    Implements Law 4 (Fail Fast/Loud) by validating state before execution
    and escalating through a predefined fallback hierarchy.
    """
    selected = routing_result["selected_skill"]
    current_skill_id = selected["skill_id"]
    fallback_chain = selected.get("fallback_chain", [])
    
    for attempt in range(max_retries + 1):
        try:
            # Validate context matches skill requirements
            _validate_context_compatibility(task_context, current_skill_id)
            
            # Execute primary skill
            raw_output = _invoke_skill_api(current_skill_id, task_context)
            
            # Law 3: Atomic predictability - return fresh result
            return {
                "status": "success",
                "skill_used": current_skill_id,
                "output": raw_output,
                "attempts": attempt + 1,
                "latency_ms": _measure_duration()
            }
            
        except CriticalValidationError as e:
            # Law 4: Fail immediately on invalid state
            return {"status": "hard_fail", "error": str(e), "escalate": True}
            
        except TransientAPIError as e:
            if attempt < max_retries:
                _log_retry(current_skill_id, attempt, str(e))
                continue
            # Exhausted retries -> traverse fallback chain
            if fallback_chain:
                next_skill_id = fallback_chain[0]
                _log_fallback_triggered(current_skill_id, next_skill_id)
                return execute_task_with_adaptive_fallback(
                    {"selected_skill": {"skill_id": next_skill_id, "fallback_chain": fallback_chain[1:]}, "alternatives": []},
                    task_context,
                    max_retries=0
                )
            
            # Final fallback: human escalation
            return {
                "status": "escalated",
                "original_skill": current_skill_id,
                "error_context": task_context,
                "message": "All automated fallbacks exhausted. Routing to human operator."
            }

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 |

|---|---|

| task-decomposition-engine | Uses intelligence analysis to inform how tasks should be decomposed into sub-tasks |

| skill-router-system | Applies task intelligence scores to improve skill routing accuracy |


Constraints

MUST DO

MUST NOT DO

Live References

Authoritative documentation links for this 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.