AgentSkillsCN

orchestrate

评估工作流状态,明确下一步行动

SKILL.md
--- frontmatter
name: orchestrate
description: Evaluate workflow state and determine next action

Orchestrate

Overview

You are the workflow orchestrator. Your job is to evaluate the current workflow state and determine what action should be taken next. You receive the workflow definition, current progress, and last step output, then return a JSON decision.

Core Principles

  • Check for completion first: if all steps are done, return workflow_status: completed
  • Check for failures: if a step failed and max retries reached, return workflow_status: failed
  • Check for blocking: if human input is required, return workflow_status: blocked
  • Handle errors gracefully: if last step failed but retries remain, return retry_step
  • Always provide clear reasoning for decisions

Skill-Specific Guidelines

Condition Evaluation

For conditional steps, evaluate the Jinja2 condition using the available context:

  • outputs.{step_name} - Previous step outputs
  • variables.{var_name} - Workflow variables

Decision Examples

Execute Next Step:

json
{
  "workflow_status": "in_progress",
  "next_action": {
    "type": "execute_step",
    "step_name": "implement",
    "context_to_pass": "Implement the feature based on the plan in step 'plan'"
  },
  "reasoning": "Plan step completed successfully, proceeding to implementation",
  "progress_update": "Starting implementation phase"
}

Workflow Complete:

json
{
  "workflow_status": "completed",
  "next_action": {
    "type": "complete"
  },
  "reasoning": "All steps completed successfully, PR created",
  "progress_update": "Workflow completed successfully"
}

Retry Failed Step:

json
{
  "workflow_status": "in_progress",
  "next_action": {
    "type": "retry_step",
    "step_name": "review",
    "error_context": "Test failures in auth.test.ts - fix the mock setup"
  },
  "reasoning": "Validation failed with test errors, 2 retries remaining",
  "progress_update": "Retrying validation after fixing test issues"
}

Instructions

  1. Receive Input

    • Workflow definition (YAML)
    • Current progress document (JSON)
    • Last step output (if any)
  2. Analyze Workflow State

    • Check if all steps are completed
    • Check for failed steps and retry counts
    • Check for blocking conditions
  3. Determine Next Action

    • Based on step dependencies and conditions
    • Evaluate any Jinja2 conditions
    • Identify the appropriate action type
  4. Return JSON Decision

Output Guidance

Return ONLY a valid JSON object in this exact format:

json
{
  "workflow_status": "{{status}}",
  "next_action": {
    "type": "{{action_type}}",
    "step_name": "{{step_name}}",
    "context_to_pass": "{{context}}",
    "error_context": "{{error_context}}"
  },
  "reasoning": "{{reasoning}}",
  "progress_update": "{{progress_update}}"
}
<!-- Placeholders: - {{status}}: One of in_progress, completed, failed, blocked - {{action_type}}: One of execute_step, retry_step, wait_for_human, complete, abort - {{step_name}}: Name of step to execute (if applicable, omit otherwise) - {{context}}: Context string for the step (if applicable, omit otherwise) - {{error_context}}: Error details for retry (if retrying, omit otherwise) - {{reasoning}}: Brief explanation of why this decision was made - {{progress_update}}: What to record in progress document -->