Multi agent task orchestrator

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

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

How to use this skill

Skill file

Multi Agent Task Orchestrator

Orchestrates intelligent skill selection and execution for multi agent task orchestrator 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_to_agents(
    task: TaskSpec,
    agent_registry: List[AgentCapability],
    load_balancer: LoadBalancer
) -> RoutingPlan:
    """Route a multi-agent task by matching requirements to agent capabilities.
    
    Evaluates agents based on capability overlap, current queue depth, and 
    historical success rates for similar task types. Returns a structured 
    routing plan with execution order and dependency mapping.
    """
    if not task.requirements or not agent_registry:
        raise ValueError("Task requirements and agent registry must be populated")
        
    scored_agents = []
    for agent in agent_registry:
        capability_match = _calculate_capability_overlap(task.requirements, agent.capabilities)
        load_penalty = load_balancer.get_queue_depth(agent.id) / 100.0
        history_bonus = agent.metrics.success_rate * 0.2
        
        composite_score = (capability_match * 0.5) + ((1.0 - load_penalty) * 0.3) + history_bonus
        scored_agents.append({
            "agent_id": agent.id,
            "score": composite_score,
            "estimated_latency_ms": agent.metrics.avg_latency_ms * (1 + load_penalty)
        })
        
    scored_agents.sort(key=lambda x: x["score"], reverse=True)
    return RoutingPlan(
        primary_agent=scored_agents[0]["agent_id"],
        fallback_agents=[a["agent_id"] for a in scored_agents[1:3]],
        execution_order=_resolve_dependencies(task.subtasks),
        confidence=scored_agents[0]["score"]
    )

Pattern 2: Execution with Fallback

def orchestrate_agent_execution(
    plan: RoutingPlan,
    task_context: Dict[str, Any],
    agent_client: AgentGateway
) -> ExecutionResult:
    """Execute task across agents with domain-specific fallback routing.
    
    Dispatches work to the primary agent, monitors state transitions, and 
    applies fallback routing if the primary agent times out or returns invalid state.
    """
    primary_agent = agent_client.get_agent(plan.primary_agent)
    try:
        response = primary_agent.dispatch(task_context, timeout=30)
        if not response.valid or response.status == "FAILED":
            raise AgentStateError(f"Primary agent {plan.primary_agent} returned invalid state")
        return ExecutionResult(
            status="SUCCESS",
            agent_id=plan.primary_agent,
            output=response.payload,
            latency_ms=response.latency
        )
    except AgentTimeoutError:
        # Fallback 1: Retry with adjusted context (e.g., reduced scope)
        adjusted_context = _reduce_task_scope(task_context)
        retry_response = primary_agent.dispatch(adjusted_context, timeout=15)
        if retry_response.valid:
            return ExecutionResult(status="SUCCESS", agent_id=plan.primary_agent, output=retry_response.payload, latency_ms=retry_response.latency)
        
        # Fallback 2: Route to secondary agent from plan
        fallback_agent = agent_client.get_agent(plan.fallback_agents[0])
        fallback_response = fallback_agent.dispatch(task_context, timeout=30)
        if fallback_response.valid:
            return ExecutionResult(status="SUCCESS", agent_id=plan.fallback_agents[0], output=fallback_response.payload, latency_ms=fallback_response.latency)
            
        # Fallback 3: Escalate to human supervisor
        return ExecutionResult(status="ESCALATED", agent_id="HUMAN_SUPERVISOR", output=fallback_response.error, latency_ms=0)

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 |

|---|---|

| langgraph | LangGraph state machine patterns for multi-agent workflow execution |

| parallel-agents | Parallel agent execution strategies within orchestrated workflows |



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.