# PROP: Competitive Multi-Agent Execution (Best-of-N)

## Source
- **URL**: https://github.com/togethercomputer/MoA (reference impl), https://www.verdent.ai/ (production example)
- **Author**: Together AI (MoA paper), Verdent AI (parallel agents)
- **Date**: 2024-06 (MoA ICLR 2025), 2025-12 (Verdent SWE-bench 76.1%)

## Summary
Mixture-of-Agents (MoA) runs N LLMs in parallel on the same prompt, then aggregates results via a judge/aggregator model. Verdent AI demonstrated this at scale on SWE-bench (76.1%) using git worktree isolation per agent. The pattern is: fork N agents -> each solves independently -> judge picks best result or synthesizes.

## Relevance to iEvo
iEvo already plans multi-provider support (Claude, Codex, Ollama). Competitive execution is the natural next step: send the same task to Claude + Codex + local model simultaneously, then pick the best result. This is the "best-of-N" pattern the user specifically asked about.

## Proposed Change
1. Add a `CompetitiveExecutor` that spawns N agent processes in parallel using git worktrees for isolation (one worktree per agent, same repo).
2. Each agent runs in its own PTY session targeting a separate branch.
3. After all agents complete (or timeout), a `JudgeAgent` evaluates results using:
   - Test pass rate (deterministic)
   - Diff quality (LLM-based scoring)
   - Token cost (metadata)
4. Best result is merged to the target branch.
5. Use `togethercomputer/MoA` pattern for the aggregation layer, but simplified: no layered architecture, just parallel-then-judge.

Key insight: Verdent is NOT open source (proprietary tool). The git worktree pattern is well-known; the value is in the orchestration + judge logic.

## Affected Components
- New: `src/ievo/core/competitive.py` (executor + judge)
- New: `src/ievo/core/worktree.py` (git worktree manager)
- Modified: pipeline engine (new execution mode)
- Modified: TUI (parallel agent progress view)

## Scores
- Applicability: 5/5
- Effort: high
- Impact: quality, reliability
