---
name: LLM-Native Execution Orchestrator
version: 1.0.0
role: Orchestrate parallel execution across LLM platforms
description: Provides platform-agnostic orchestration patterns for parallel development with intelligent coordination and dynamic adaptation
capabilities:
  - Multi-platform execution patterns
  - Wave management and coordination
  - Dynamic plan adaptation
  - Quality gate integration
  - Real-time progress tracking
---

# LLM-Native Execution Orchestrator

## Purpose

Provides platform-agnostic orchestration patterns for parallel development execution across different LLM engines. Enables intelligent coordination, progress tracking, and dynamic adaptation without relying on specific tool implementations.

## Core Capabilities

### 1. Multi-Platform Execution Patterns

- **Claude**: Concurrent Task tool deployment
- **GPT**: Parallel function calling with threads
- **Gemini**: Batch processing with correlation
- **Open Source**: Prompt-based coordination
- **Generic**: Numbered agent instructions

### 2. Intelligent Coordination

- **Wave Management**: Sequential wave execution
- **Progress Tracking**: Real-time status monitoring
- **Dynamic Adaptation**: Plan adjustments during execution
- **Quality Gates**: Automated validation checkpoints

### 3. Communication Protocols

- **Status Updates**: Standardized progress reporting
- **Error Handling**: Graceful failure management
- **Result Aggregation**: Unified output collection
- **Conflict Resolution**: Real-time intervention

## Orchestration Framework

### Execution Plan Structure

```json
{
  "orchestrationId": "sprint-2024-03-parallel",
  "platform": "auto-detect|claude|gpt|gemini|generic",
  "executionMode": "waves|continuous|adaptive",
  "waves": [
    {
      "waveId": "wave-1",
      "parallel": true,
      "agents": [
        {
          "agentId": "AUTH_IMPL",
          "workDescription": "Implement OAuth2 authentication",
          "scope": "auth-service",
          "estimatedDuration": "2h",
          "dependencies": [],
          "qualityGates": ["unit-tests", "security-scan"]
        }
      ]
    }
  ],
  "coordinationRules": {
    "conflictHandling": "pause-and-resolve",
    "progressReporting": "every-30-min",
    "failureStrategy": "continue-others"
  }
}
```

### Platform-Specific Patterns

#### Claude Pattern

```markdown
## PARALLEL EXECUTION ORCHESTRATION

Deploy the following agents concurrently using Task tool:

**WAVE 1 - Launch Simultaneously**
Task 1: AUTH_AGENT - Implement OAuth2 in auth-service
Task 2: LOG_AGENT - Add structured logging
Task 3: CACHE_AGENT - Implement Redis caching

**Coordination Protocol**

- Each agent reports status every 30 minutes
- On completion, update status file
- On failure, alert orchestrator
```

#### GPT Pattern

```python
# Parallel Execution with Threads
async def execute_wave_1():
    threads = []

    # Create parallel threads
    auth_thread = create_thread("AUTH: Implement OAuth2")
    log_thread = create_thread("LOG: Add structured logging")
    cache_thread = create_thread("CACHE: Implement Redis")

    # Execute concurrently
    results = await asyncio.gather(
        run_thread(auth_thread),
        run_thread(log_thread),
        run_thread(cache_thread)
    )

    return aggregate_results(results)
```

#### Generic LLM Pattern

```markdown
## MULTI-AGENT PARALLEL EXECUTION

You are orchestrating 3 development agents working in parallel.

### Agent Instructions

**[AGENT-1: AUTHENTICATION]**

- Task: Implement OAuth2 authentication
- Working Directory: ./auth-service
- Branch: feature/oauth2
- Report Status: Every 30 minutes to orchestrator

**[AGENT-2: LOGGING]**

- Task: Add structured logging system
- Working Directory: ./logging-service
- Branch: feature/structured-logs
- Report Status: Every 30 minutes to orchestrator

**[AGENT-3: CACHING]**

- Task: Implement Redis caching layer
- Working Directory: ./cache-service
- Branch: feature/redis-cache
- Report Status: Every 30 minutes to orchestrator

### Coordination Rules

1. All agents start simultaneously
2. No shared file modifications
3. Report progress using STATUS markers
4. On completion, mark as [COMPLETE]
5. On failure, mark as [FAILED] with reason
```

## Dynamic Orchestration

### Adaptive Execution

```javascript
class LLMOrchestrator {
  async executeAdaptive(plan) {
    let currentPlan = plan;

    while (!this.isComplete(currentPlan)) {
      // Execute current wave
      const results = await this.executeWave(currentPlan.currentWave);

      // Analyze results
      const analysis = await this.llmAnalyzer.analyzeProgress(results);

      // Adapt plan if needed
      if (analysis.requiresAdaptation) {
        currentPlan = await this.llmPlanner.adaptPlan(
          currentPlan,
          analysis.recommendations,
        );
      }

      // Move to next wave
      currentPlan.currentWave++;
    }

    return this.aggregateResults(currentPlan);
  }
}
```

### Progress Tracking Protocol

```yaml
Status Markers:
  - "[STATUS: STARTED] Agent beginning work"
  - "[STATUS: PROGRESS-25%] Initial implementation"
  - "[STATUS: PROGRESS-50%] Core features complete"
  - "[STATUS: PROGRESS-75%] Testing in progress"
  - "[STATUS: COMPLETE] All tasks finished"
  - "[STATUS: FAILED] Error encountered"
  - "[STATUS: BLOCKED] Waiting for dependency"

Progress Report Format:
  agentId: AUTH_IMPL
  status: PROGRESS-50%
  completedTasks:
    - OAuth2 provider implementation
    - JWT token generation
  remainingTasks:
    - Integration tests
    - Documentation
  blockers: none
  estimatedCompletion: 1 hour
```

## Quality Gate Integration

### Automated Validation

```json
{
  "qualityGates": {
    "wave1": {
      "gates": ["unit-tests", "linting", "security-scan"],
      "failureAction": "pause-wave",
      "successAction": "proceed-to-wave2"
    },
    "wave2": {
      "gates": ["integration-tests", "performance-tests"],
      "failureAction": "rollback-and-retry",
      "successAction": "proceed"
    },
    "final": {
      "gates": ["e2e-tests", "security-audit", "documentation"],
      "failureAction": "manual-review",
      "successAction": "merge-all"
    }
  }
}
```

### Gate Execution Prompts

```markdown
## QUALITY GATE: Unit Tests

Run unit tests for completed work in Wave 1:

1. Execute test suite for AUTH service
2. Execute test suite for LOG service
3. Execute test suite for CACHE service

Report results in format:
[GATE: unit-tests] Service: AUTH - PASSED (45/45 tests)
[GATE: unit-tests] Service: LOG - FAILED (2/30 tests failed)

If any failures, provide:

- Failed test names
- Error messages
- Suggested fixes
```

## Communication Templates

### Status Aggregation

```javascript
// Collect status from all agents
function aggregateStatus(agents) {
  return {
    timestamp: new Date().toISOString(),
    overallProgress: calculateAverage(agents.map((a) => a.progress)),
    agentStatus: agents.map((a) => ({
      id: a.id,
      status: a.status,
      progress: a.progress,
      blockers: a.blockers,
    })),
    risks: identifyRisks(agents),
    recommendations: generateRecommendations(agents),
  };
}
```

### Error Recovery

```markdown
## ERROR RECOVERY PROTOCOL

When an agent fails:

1. **Immediate Actions**
   - Pause affected wave
   - Notify orchestrator
   - Preserve work state

2. **Analysis**
   - Determine failure cause
   - Assess impact on other agents
   - Identify recovery options

3. **Recovery Options**
   - Retry with fixes
   - Skip and continue
   - Rollback and replan
   - Manual intervention

4. **Communication**
   [ERROR: Agent AUTH_IMPL failed]
   Cause: Database connection timeout
   Impact: Blocks PROFILE_IMPL in wave 2
   Recommendation: Fix connection and retry
```

## Advanced Features

### 1. Predictive Orchestration

```yaml
Predictive Capabilities:
  - Estimate completion times using historical data
  - Predict bottlenecks before they occur
  - Suggest optimal agent allocation
  - Identify risk patterns early
```

### 2. Resource Optimization

```yaml
Resource Management:
  - Dynamic agent allocation based on workload
  - Automatic work rebalancing
  - Idle resource detection
  - Optimal wave composition
```

### 3. Intelligent Monitoring

```yaml
Monitoring Features:
  - Anomaly detection in progress patterns
  - Quality trend analysis
  - Performance optimization suggestions
  - Automated alert generation
```

## Usage Examples

### Basic Parallel Execution

```bash
# Execute with automatic platform detection
llm-orchestrate \
  --plan "parallel-plan.json" \
  --mode "waves" \
  --platform "auto"
```

### Adaptive Execution

```bash
# Execute with dynamic adaptation
llm-orchestrate \
  --plan "parallel-plan.json" \
  --mode "adaptive" \
  --risk-tolerance "medium" \
  --quality-gates "strict"
```

### Custom Platform

```bash
# Execute with specific platform pattern
llm-orchestrate \
  --plan "parallel-plan.json" \
  --platform "gemini" \
  --batch-size 5 \
  --correlation-mode "enabled"
```

## Benefits

1. **Platform Agnostic**: Works with any LLM engine
2. **Intelligent Coordination**: Smart wave management
3. **Dynamic Adaptation**: Responds to execution reality
4. **Quality Assured**: Integrated validation gates
5. **Observable**: Complete execution transparency
6. **Resilient**: Graceful error handling

This orchestrator enables sophisticated parallel development coordination across any LLM platform while maintaining quality and efficiency.
