Temporal python pro

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

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

How to use this skill

Skill file

Temporal Python Pro

Orchestrates intelligent skill selection and execution for temporal python pro 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_temporal_task(
    task_payload: Dict[str, Any],
    skill_registry: List[Dict[str, Any]],
    confidence_threshold: float = 0.75
) -> Dict[str, Any]:
    """Route a temporal workflow task to the optimal agent skill.
    
    Implements multi-factor scoring: lexical match, historical success rate,
    current system load, and dependency health. Enforces Law 2 (Parse at boundary)
    and Law 1 (Early exit on invalid state).
    """
    if not task_payload.get("intent") or not task_payload.get("temporal_constraints"):
        raise ValueError("Missing required temporal intent or constraints")
        
    intent = task_payload["intent"].lower()
    constraints = task_payload["temporal_constraints"]
    
    scored_candidates = []
    for skill in skill_registry:
        if not skill.get("active"):
            continue
            
        # Factor 1: Lexical/Intent Match
        intent_match = _calculate_semantic_similarity(intent, skill["triggers"])
        
        # Factor 2: Historical Performance
        history_score = skill.get("success_rate", 0.0)
        
        # Factor 3: System Availability & Load
        availability = 1.0 - (skill.get("current_load", 0.0) / 100.0)
        
        # Factor 4: Dependency Health
        deps_healthy = all(
            _check_dependency_health(dep) for dep in skill.get("dependencies", [])
        )
        if not deps_healthy:
            continue
            
        # Weighted Multi-Factor Score
        raw_score = (
            0.4 * intent_match +
            0.3 * history_score +
            0.2 * availability +
            0.1 * (1.0 if deps_healthy else 0.0)
        )
        
        if raw_score >= confidence_threshold:
            scored_candidates.append({
                "skill": skill,
                "score": raw_score,
                "factors": {
                    "intent": intent_match,
                    "history": history_score,
                    "availability": availability
                }
            })
            
    if not scored_candidates:
        return {"status": "no_match", "fallback_required": True}
        
    scored_candidates.sort(key=lambda x: x["score"], reverse=True)
    best = scored_candidates[0]
    
    # Law 3: Return new structure, never mutate registry
    return {
        "status": "selected",
        "skill_id": best["skill"]["id"],
        "confidence": best["score"],
        "routing_metadata": best["factors"],
        "timestamp": time.time()
    }

Pattern 2: Execution with Fallback

def execute_with_temporal_fallback(
    selected_skill: Dict[str, Any],
    task_context: Dict[str, Any],
    fallback_chain: List[Dict[str, Any]],
    max_retries: int = 2
) -> Dict[str, Any]:
    """Execute an agent skill with a domain-specific fallback chain.
    
    Enforces Law 4 (Fail Fast/Loud) and Law 1 (Early Exit).
    Implements retry -> alternative skill -> human escalation.
    """
    if not selected_skill or not task_context.get("task_id"):
        raise ValueError("Missing skill metadata or task context")
        
    skill_id = selected_skill["skill_id"]
    context = copy.deepcopy(task_context) # Law 3: Immutable inputs
    
    for attempt in range(max_retries + 1):
        try:
            # Execute with temporal timeout enforcement
            result = _run_skill_with_timeout(
                skill_id, context, timeout_seconds=selected_skill.get("timeout", 30)
            )
            
            return {
                "status": "success",
                "skill_id": skill_id,
                "result": result,
                "attempts": attempt + 1,
                "latency_ms": time.time() * 1000
            }
            
        except TemporalTimeoutError:
            if attempt < max_retries:
                continue # Retry
            raise # Fail Loud on timeout
            
        except AgentExecutionError as e:
            if attempt < max_retries:
                continue # Retry with backoff
            
            # Fallback Chain Execution
            for fallback_skill in fallback_chain:
                try:
                    fallback_result = _run_skill_with_timeout(
                        fallback_skill["skill_id"], context, timeout_seconds=30
                    )
                    return {
                        "status": "fallback_success",
                        "original_skill": skill_id,
                        "fallback_skill": fallback_skill["skill_id"],
                        "result": fallback_result
                    }
                except Exception:
                    continue
                    
            # Final Fallback: Human Escalation
            return {
                "status": "escalated",
                "reason": "All automated fallbacks exhausted",
                "task_context": context,
                "requires_human_review": True
            }

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 |

|---|---|

| temporal-golang-pro | Go equivalent of the Temporal workflow patterns covered in this Python-focused skill |

| workflow-patterns | General workflow orchestration patterns that complement Temporal-specific implementations |


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.