CtrlK
BlogDocsLog inGet started
Tessl Logo

Three AI Orchestrator

Multi-model review chain coordinating Claude Opus 4.6, GPT-5.1-Codex, and GLM-4.6v for maximum code quality

Invalid
This skill can't be scored yet
Validation errors are blocking scoring. Review and fix them to unlock Quality, Impact and Security scores. See what needs fixing →
SKILL.md
Quality
Evals
Security

🦞 Three AI Orchestrator

Advanced multi-model orchestration algorithm that coordinates 3 specialized AI models in a review chain for maximum code quality and consensus-driven outputs.

Overview

The Three AI Orchestrator implements a sophisticated workflow where three AI models collaborate:

  1. Claude Opus 4.6 (Primary Lead) - Planning and initial implementation
  2. GPT-5.1-Codex (Code Reviewer) - Error detection and code review
  3. GLM-4.6v (Multimodal Consultant) - Final review and validation

Architecture

┌─────────────────────────────────────────────────────────┐
│                  3-AI ORCHESTRATOR                       │
│                                                          │
│  ┌──────────────┐   ┌──────────────┐   ┌────────────┐  │
│  │ Claude Opus  │──►│  GPT Codex   │──►│   GLM-4.6v  │  │
│  │   (Plan &    │   │  (Review &   │   │  (Final     │  │
│  │    Code)     │   │   Verify)    │   │   Check)    │  │
│  └──────────────┘   └──────────────┘   └────────────┘  │
│         │                   │                  │         │
│         └───────────────────┴──────────────────┘         │
│                      Consensus Check                     │
│                                                          │
│         ✅ Pass → Return Result                          │
│         ❌ Fail → Iterate with Feedback                  │
└─────────────────────────────────────────────────────────┘

Features

  • Multi-Model Consensus: 3 AIs must agree for approval
  • Iterative Refinement: Up to N iterations with feedback
  • Role Specialization: Each AI has specific responsibilities
  • Quality Guarantee: Multiple perspectives reduce errors
  • Detailed Reviews: Each AI provides issues, suggestions, insights

AI Roles & Responsibilities

1. Claude Opus 4.6 (Primary Lead)

Provider: V98Store
Priority: 1 (First to execute)

Strengths:

  • Best-in-class reasoning and planning
  • 200K context window
  • Multi-step task decomposition
  • Complex problem solving

Responsibilities:

  • Understand requirements
  • Design solution architecture
  • Write initial code implementation
  • Explain approach

2. GPT-5.1-Codex (Code Reviewer)

Provider: V98Store
Priority: 2 (Reviews Opus output)

Strengths:

  • God-level programming AI
  • Zero-error code verification
  • Security vulnerability detection
  • Performance optimization

Responsibilities:

  • Review code for bugs
  • Detect security issues
  • Check best practices
  • Suggest optimizations

3. GLM-4.6v (Multimodal Consultant)

Provider: V98Store
Priority: 3 (Final validation)

Strengths:

  • Multimodal (vision + text)
  • 128K context window
  • Frontend replication
  • Visual code analysis

Responsibilities:

  • Final sanity check
  • Cross-verify Opus and Codex
  • Provide consultant insights
  • Approve or reject

Usage

Basic Usage

from core.orchestrator.three_ai_orchestrator import ThreeAIOrchestrator

orchestrator = ThreeAIOrchestrator()

result = orchestrator.execute({
    "request": "Create a Python function to parse JSON with error handling",
    "max_iterations": 3
})

if result.status == "success" and result.data['consensus']:
    print(f"✅ All 3 AIs agreed!")
    print(result.data['result'])
else:
    print(f"⚠️  Partial consensus or no agreement")
    print(f"Reviews: {result.data['reviews']}")

With Context

result = orchestrator.execute({
    "request": "Design a REST API for blog posts",
    "context": {
        "requirements": [
            "User authentication",
            "CRUD for posts",
            "Comments support"
        ],
        "tech_stack": "FastAPI + PostgreSQL"
    },
    "max_iterations": 2
})

Advanced Configuration

# Custom iteration handling
result = orchestrator.execute({
    "request": "Optimize this database query",
    "context": {
        "current_query": "SELECT * FROM users WHERE ...",
        "performance_target": "< 100ms"
    },
    "max_iterations": 5  # Allow more refinement
})

# Check individual reviews
opus_review = result.data['reviews']['opus']
codex_review = result.data['reviews']['codex']
glm_review = result.data['reviews']['glm']

print(f"Opus confidence: {opus_review['confidence']:.0%}")
print(f"Codex issues found: {len(codex_review['issues'])}")
print(f"GLM approved: {glm_review['approved']}")

Workflow

Iteration Process

START
  ↓
Iteration 1:
  [1] Opus: Plans and codes
  [2] Codex: Reviews for errors
  [3] GLM: Final validation
  ↓
Consensus Check:
  ✅ All approved? → RETURN SUCCESS
  ❌ Not approved? → Collect feedback
  ↓
Iteration 2:
  [1] Opus: Refines with feedback
  [2] Codex: Re-reviews
  [3] GLM: Re-validates
  ↓
... (repeat up to max_iterations)
  ↓
END

Result Structure

{
    "status": "success" | "partial" | "error",
    "data": {
        "result": "Final output from Opus",
        "consensus": True | False,
        "iterations": 2,
        "reviews": {
            "opus": {
                "ai_role": "primary_lead",
                "model": "claude-opus-4.6",
                "approved": True,
                "confidence": 0.95,
                "issues": [],
                "suggestions": [],
                "insights": ["..."],
                "processing_time": 3.2
            },
            "codex": {...},
            "glm": {...}
        },
        "total_time": 8.5
    }
}

Use Cases

1. Critical Code Generation

When code must be bug-free and production-ready.

result = orchestrator.execute({
    "request": "Create a secure payment processing function"
})

2. Architecture Design

When multiple perspectives improve design quality.

result = orchestrator.execute({
    "request": "Design microservices architecture for e-commerce"
})

3. Code Review

When reviewing complex or security-critical code.

result = orchestrator.execute({
    "request": "Review this authentication implementation",
    "context": {"code": existing_code}
})

4. Debugging

When root cause is unclear.

result = orchestrator.execute({
    "request": "Debug this memory leak",
    "context": {"symptoms": [...], "code": buggy_code}
})

Best Practices

1. Set Appropriate Iterations

simple_tasks = {"max_iterations": 2}      # Quick tasks
complex_tasks = {"max_iterations": 5}     # Complex problems
critical_tasks = {"max_iterations": 3}    # Balance quality/time

2. Provide Clear Context

# Good
result = orchestrator.execute({
    "request": "Optimize database query",
    "context": {
        "current_performance": "2s",
        "target": "< 100ms",
        "database": "PostgreSQL 14",
        "table_size": "10M rows"
    }
})

# Bad
result = orchestrator.execute({
    "request": "Make it faster"
})

3. Handle Non-Consensus

result = orchestrator.execute({...})

if not result.data.get('consensus'):
    # Extract common themes from reviews
    all_issues = (
        result.data['reviews']['codex']['issues'] +
        result.data['reviews']['glm']['issues']
    )
    # Address issues manually or re-run

4. Monitor Performance

total_time = result.data['total_time']
iterations = result.data['iterations']
avg_time_per_iteration = total_time / iterations

if avg_time_per_iteration > 10:
    print("⚠️  Slow performance, consider:")
    print("  - Reducing max_tokens")
    print("  - Using simpler models for simple tasks")
    print("  - Caching similar requests")

Performance

MetricValue
Avg time per iteration5-10s
Typical iterations1-2
Consensus rate (quality tasks)85%
False negative rate<5%

Limitations

  1. Cost: 3x API calls per iteration (3 models)
  2. Time: 5-10s per iteration (sequential execution)
  3. Consensus: May not reach agreement on subjective tasks
  4. Token Limits: Each model has token constraints

Troubleshooting

IssueSolution
No consensus after max iterationsIncrease max_iterations or simplify request
All AIs rejectRequest may be ambiguous, add more context
Slow performanceReduce max_tokens, use fewer iterations
API errorsCheck V98 connection, verify API key

Related Algorithms

  • V98Connection: Powers the API calls
  • CodeReviewer: Single-model alternative
  • SmartOrchestrator: General-purpose orchestration

File Location

D:\Antigravity\Dive AI\core\orchestrator\three_ai_orchestrator.py

Version

v1.0 - Initial release with 3-model consensus workflow

Repository
duclm1x1/Dive-Ai
Last updated
Created

Is this your skill?

If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.