model-debate

Use when any task benefits from multiple AI models debating — spec design (debate), content writing (best-of-n), or code review (verify). Dispatches up to 9 frontier models from Anthropic, xAI, Google, Xiaomi, Moonshot, MiniMax, Zhipu, Alibaba in parallel via Zenmux + 百炼 gateway. Runs layered quality gates with quorum-based collection and role-differentiated prompts.

Model Debate v3: All-Star Multi-Model Orchestra

Overview

9 frontier models from 8 labs. Two unified gateways. Parallel fan-out. Role-differentiated prompts. Opus always decides.

CC (Opus, current session) orchestrates. All other models are dispatched via two Anthropic-compatible gateways — Zenmux (6 models) and 百炼 (2 models). Same curl template, different credentials. Simple.

When to Use

  • Writing specs, PRDs, design proposals → debate preset
  • Writing content for publishing → best_of_n preset
  • Reviewing code or technical artifacts → verify preset
  • Any task where the user wants multi-model collaboration

Do NOT use for: trivial edits, quick questions, tasks the user wants done fast.


Model Pool (8 participants + 1 orchestrator)

#ModelLabGatewayModel IDStrengths
0Claude Opus 4.6AnthropicCurrent sessionOrchestrator. Synthesizes, arbitrates, final judge.
1Claude Opus 4.6AnthropicZenmuxanthropic/claude-opus-4.6Fresh-context Opus as independent reviewer
2Grok 4xAIZenmuxx-ai/grok-4Strong reasoning, unconventional angles
3Gemini 3.1 ProGoogleZenmuxgoogle/gemini-3.1-pro-previewLong context, web-grounded, multimodal
4MiMo V2 ProXiaomiZenmuxxiaomi/mimo-v2-proMoE reasoning, thinking model
5Kimi K2.5MoonshotZenmuxmoonshotai/kimi-k2.5Strong Chinese, long context, detail-oriented
6MiniMax M2.7MiniMaxZenmuxminimax/minimax-m2.7-highspeedFast, thinking model
7GLM-5Zhipu AI百炼glm-5Fast MoE, constraint analysis
8Qwen-3.5-PlusAlibaba百炼qwen3.5-plusStrong reasoning, counterexamples

8 participants from 8 different labs = maximum perspective diversity.


Two Gateways, One Protocol

Both gateways speak Anthropic Messages API. Dispatch is identical except for credentials.

Credentials

Keys must be set as environment variables (never hardcode):

# Gateway 1: Zenmux (Claude, Grok, Gemini, MiMo, Kimi, MiniMax)
# export ZENMUX_KEY="your-zenmux-key"
ZENMUX_BASE="https://zenmux.ai/api/anthropic"

# Gateway 2: 百炼 (GLM-5, Qwen-3.5-Plus)
# export BAILIAN_KEY="your-bailian-key"
BAILIAN_BASE="https://coding.dashscope.aliyuncs.com/apps/anthropic"

Universal Dispatch Template

Every model uses the same curl pattern. Only BASE, KEY, and MODEL vary:

# 1. Write prompt to file
cat > /tmp/mm-{tag}-prompt.md <<'PROMPT_EOF'
{rendered prompt envelope}
PROMPT_EOF

# 2. Build request JSON
python3 -c "
import json
prompt = open('/tmp/mm-{tag}-prompt.md').read()
req = {
    'model': '{MODEL_ID}',
    'max_tokens': 4096,
    'messages': [{'role': 'user', 'content': prompt}]
}
json.dump(req, open('/tmp/mm-{tag}-request.json', 'w'), ensure_ascii=False)
"

# 3. Dispatch + parse (MUST strip control chars)
curl -s -m 120 {BASE}/v1/messages \
  -H "x-api-key: {KEY}" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d @/tmp/mm-{tag}-request.json \
  | perl -pe 's/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]//g' \
  | python3 -c "
import sys, json
d = json.load(sys.stdin)
for c in d.get('content', []):
    if c.get('type') == 'text':
        print(c['text'])
" > /tmp/mm-{tag}-output.txt 2>/tmp/mm-{tag}-error.txt

Critical notes:

  • perl -pe strip is mandatory — thinking models (MiMo, MiniMax, Kimi) emit control chars
  • Thinking models (MiMo, MiniMax) return thinking blocks before text blocks — the parser above already handles this by filtering for type == 'text'
  • Use max_tokens: 4096 for cloud models (enough for detailed review, not wasteful)
  • Timeout 120s per model — some thinking models need time

Dispatch Table (copy-paste ready)

TagGatewayKEY varMODEL_ID
opus2ZenmuxZENMUX_KEYanthropic/claude-opus-4.6
grokZenmuxZENMUX_KEYx-ai/grok-4
geminiZenmuxZENMUX_KEYgoogle/gemini-3.1-pro-preview
mimoZenmuxZENMUX_KEYxiaomi/mimo-v2-pro
kimiZenmuxZENMUX_KEYmoonshotai/kimi-k2.5
minimaxZenmuxZENMUX_KEYminimax/minimax-m2.7-highspeed
glm5百炼BAILIAN_KEYglm-5
qwen百炼BAILIAN_KEYqwen3.5-plus

Prompt Envelope

Every model gets one semantic envelope with role-specific framing:

## Role
{role assignment — see Role Matrix below}

## Brief
{the shared problem statement — IDENTICAL for all models}

## Context
{inlined code/files/data}

## Constraints
- Only address the brief; do not add unrelated topics
- Required output sections: {list}
- Output language: Chinese
- Max ~1500 words

## Output Format
{required sections}

End with:
### Confidence: [high | medium | low]
### Key Risk: {one sentence}

Role Assignment Matrix

verify preset (code review)

#ModelRoleFocus
1Claude Opus (Zenmux)Lead ReviewerArchitecture, design patterns, code quality
2Grok 4Devil's AdvocateChallenge assumptions, unconventional critique
3Gemini 3.1 ProSecurity & Perf AuditorXSS, injection, perf, scalability
4MiMo V2 ProLogic VerifierReasoning correctness, edge cases
5Kimi K2.5UX & Readability CriticUser experience, naming, clarity
6MiniMax M2.7Completeness AuditorMissing features, gaps vs requirements
7GLM-5Constraint CheckerAPI contracts, error handling, robustness
8Qwen-3.5-PlusCounterexample HunterWhat could go wrong? Adversarial inputs

debate preset (spec/design)

#ModelRoleFocus
1Claude Opus (Zenmux)Proposer AFull proposal with implementation detail
2Grok 4Red TeamAttack proposals, find fatal flaws
3Gemini 3.1 ProProposer BAlternative approach, different trade-offs
4MiMo V2 ProFeasibility AnalystCan this actually work? Engineering reality check
5Kimi K2.5User AdvocateEnd-user perspective, usability
6MiniMax M2.7Scope GuardianScope creep detection, YAGNI enforcement
7GLM-5Constraint AuditorRisks, dependencies, constraints
8Qwen-3.5-PlusCounter-ProposerChallenge assumptions, counter-proposal

best_of_n preset (content)

#ModelRoleFocus
1-3Opus, Gemini, KimiDraftersEach writes a full draft
4-5Grok, MiMoCriticsRate and critique all drafts
6-8MiniMax, GLM, QwenJudgesPick best, suggest improvements

Availability Check

# Requires ZENMUX_KEY and BAILIAN_KEY env vars to be set

echo "=== Zenmux models ==="
for m in "anthropic/claude-opus-4.6" "x-ai/grok-4" "google/gemini-3.1-pro-preview" "xiaomi/mimo-v2-pro" "moonshotai/kimi-k2.5" "minimax/minimax-m2.7-highspeed"; do
  curl -s -m 10 https://zenmux.ai/api/anthropic/v1/messages \
    -H "x-api-key: $ZENMUX_KEY" -H "anthropic-version: 2023-06-01" \
    -H "content-type: application/json" \
    -d "{\"model\":\"$m\",\"max_tokens\":5,\"messages\":[{\"role\":\"user\",\"content\":\"ping\"}]}" \
    | grep -q '"content"' && echo "  $m: ✓" || echo "  $m: ✗"
done

echo "=== 百炼 models ==="
for m in "glm-5" "qwen3.5-plus"; do
  curl -s -m 10 https://coding.dashscope.aliyuncs.com/apps/anthropic/v1/messages \
    -H "x-api-key: $BAILIAN_KEY" -H "anthropic-version: 2023-06-01" \
    -H "content-type: application/json" \
    -d "{\"model\":\"$m\",\"max_tokens\":5,\"messages\":[{\"role\":\"user\",\"content\":\"ping\"}]}" \
    | grep -q '"content"' && echo "  $m: ✓" || echo "  $m: ✗"
done

The Unified Loop

1. PLAN       → CC: determine preset + stakes, run availability check
2. BRIEF      → CC: write brief, assign roles, render 8 prompt envelopes
3. FAN-OUT    → Dispatch ALL 8 models in parallel (Bash run_in_background)
                 Quorum: 5 valid outputs | Deadline: 120s
4. COLLECT    → Read all output files, validate (has text? has required sections?)
                 Failed/timeout: preserve raw, log in report, exclude from synthesis
5. SYNTHESIZE → CC: read all valid outputs
                 → map: consensus points, divergence points, unique insights per model
                 → write synthesis
6. CRITIQUE   → Pick the model whose output was LEAST reflected in synthesis
                 → dispatch one more targeted critique round
7. REVISE     → CC: incorporate critique if substantive
8. APPROVE    → CC: final check
9. DELIVER    → Output + Decision Report

Parallel Dispatch (step 3)

Use Bash run_in_background for ALL 8 models simultaneously. They all hit cloud endpoints — no local memory constraints.

# All 8 dispatch calls go out in ONE message with run_in_background=true
# Requires ZENMUX_KEY and BAILIAN_KEY env vars to be set

# Zenmux models (6x parallel)
for tag_model in "opus2:anthropic/claude-opus-4.6" "grok:x-ai/grok-4" "gemini:google/gemini-3.1-pro-preview" "mimo:xiaomi/mimo-v2-pro" "kimi:moonshotai/kimi-k2.5" "minimax:minimax/minimax-m2.7-highspeed"; do
  tag="${tag_model%%:*}"
  model="${tag_model#*:}"
  python3 -c "
import json; prompt=open(f'/tmp/mm-$tag-prompt.md').read()
json.dump({'model':'$model','max_tokens':4096,'messages':[{'role':'user','content':prompt}]}, open(f'/tmp/mm-$tag-request.json','w'), ensure_ascii=False)
"
  curl -s -m 120 https://zenmux.ai/api/anthropic/v1/messages \
    -H "x-api-key: $ZENMUX_KEY" -H "anthropic-version: 2023-06-01" \
    -H "content-type: application/json" \
    -d @/tmp/mm-$tag-request.json \
    | perl -pe 's/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]//g' \
    | python3 -c "import sys,json; d=json.load(sys.stdin); [print(c['text']) for c in d.get('content',[]) if c.get('type')=='text']" \
    > /tmp/mm-$tag-output.txt 2>/tmp/mm-$tag-error.txt &
done

# 百炼 models (2x parallel)
for tag_model in "glm5:glm-5" "qwen:qwen3.5-plus"; do
  tag="${tag_model%%:*}"
  model="${tag_model#*:}"
  python3 -c "
import json; prompt=open(f'/tmp/mm-$tag-prompt.md').read()
json.dump({'model':'$model','max_tokens':4096,'messages':[{'role':'user','content':prompt}]}, open(f'/tmp/mm-$tag-request.json','w'), ensure_ascii=False)
"
  curl -s -m 120 https://coding.dashscope.aliyuncs.com/apps/anthropic/v1/messages \
    -H "x-api-key: $BAILIAN_KEY" -H "anthropic-version: 2023-06-01" \
    -H "content-type: application/json" \
    -d @/tmp/mm-$tag-request.json \
    | perl -pe 's/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]//g' \
    | python3 -c "import sys,json; d=json.load(sys.stdin); [print(c['text']) for c in d.get('content',[]) if c.get('type')=='text']" \
    > /tmp/mm-$tag-output.txt 2>/tmp/mm-$tag-error.txt &
done

wait  # all 8 complete

Stakes Levels

StakesQuorumDeadlineExtra
High (external publish, key design)6/8120s+ mandatory critique round
Medium (specs, internal docs)5/890scritique optional
Low (drafts, notes)3/860ssingle round

Degradation Policy

AvailableBehavior
7-8 modelsFull Orchestra
5-6 modelsStandard — solid
3-4 modelsReduced — [REDUCED] marker
1-2 modelsMinimal — flag for human review
0 modelsDegraded — CC solo, [DEGRADED] marker

Error Handling

Error ClassDetectionAction
auth_errorHTTP 401/403No retry. Degrade.
transport_errorConnection reset, 5xxRetry once, 3s backoff.
timeout_error>120sMark timeout, continue.
parse_errorJSON failurePreserve raw. Fallback parse. Drop if fails.
thinking_onlyResponse has thinking blocks but no text blockRetry with max_tokens: 8192 (thinking models need more budget)
empty_textText block exists but emptyDrop, log in report.

Decision Report

## Decision Report: {task-id}
- **Preset**: debate | best_of_n | verify
- **Stakes**: high | medium | low

### Model Dispatch
| # | Model | Lab | Role | Status | Duration | Adopted |
|---|-------|-----|------|--------|----------|---------|
| 1 | Claude Opus | Anthropic | lead-reviewer | ✓ | 15.2s | full |
| 2 | Grok 4 | xAI | devil-advocate | ✓ | 11.3s | full |
| 3 | Gemini 3.1 Pro | Google | security-auditor | ✓ | 18.7s | full |
| 4 | MiMo V2 Pro | Xiaomi | logic-verifier | ✓ | 22.1s | full |
| 5 | Kimi K2.5 | Moonshot | ux-critic | ✓ | 14.5s | full |
| 6 | MiniMax M2.7 | MiniMax | completeness | ✓ | 9.8s | full |
| 7 | GLM-5 | Zhipu | constraint-checker | ✓ | 8.1s | full |
| 8 | Qwen-3.5-Plus | Alibaba | counterexample | ✓ | 10.4s | full |

### Synthesis
- **Models contributed**: 8/8
- **Consensus points**: {N}
- **Divergence points**: {N}
- **Per-model unique contributions**: {summary}

### Opus Decision: APPROVED / REVISED / FLAGGED-FOR-HUMAN

Red Flags

Do NOT:

  • Skip the perl -pe control character strip
  • Retry quality failures — longer text ≠ better thinking
  • Skip the Decision Report
  • Inline long prompts in shell arguments — always use temp files
  • Forget to increase max_tokens for thinking models (MiMo, MiniMax) if they return only thinking blocks
  • Dispatch sequentially — ALL 8 models go out in parallel

Quick Reference

# === Credentials (must be set as env vars) ===
# export ZENMUX_KEY="your-zenmux-key"
# export BAILIAN_KEY="your-bailian-key"

# === Zenmux dispatch (any of 6 models) ===
curl -s -m 120 https://zenmux.ai/api/anthropic/v1/messages \
  -H "x-api-key: $ZENMUX_KEY" -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" -d @/tmp/mm-{tag}-request.json \
  | perl -pe 's/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]//g' \
  | python3 -c "import sys,json; d=json.load(sys.stdin); [print(c['text']) for c in d.get('content',[]) if c.get('type')=='text']"

# === 百炼 dispatch (GLM-5 or Qwen-3.5-Plus) ===
curl -s -m 120 https://coding.dashscope.aliyuncs.com/apps/anthropic/v1/messages \
  -H "x-api-key: $BAILIAN_KEY" -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" -d @/tmp/mm-{tag}-request.json \
  | perl -pe 's/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]//g' \
  | python3 -c "import sys,json; d=json.load(sys.stdin); [print(c['text']) for c in d.get('content',[]) if c.get('type')=='text']"

# === Availability check ===
for m in "anthropic/claude-opus-4.6" "x-ai/grok-4" "google/gemini-3.1-pro-preview" "xiaomi/mimo-v2-pro" "moonshotai/kimi-k2.5" "minimax/minimax-m2.7-highspeed"; do
  curl -s -m 8 https://zenmux.ai/api/anthropic/v1/messages -H "x-api-key: $ZENMUX_KEY" -H "anthropic-version: 2023-06-01" -H "content-type: application/json" -d "{\"model\":\"$m\",\"max_tokens\":5,\"messages\":[{\"role\":\"user\",\"content\":\"p\"}]}" | grep -q content && echo "$m ✓" || echo "$m ✗"
done
for m in "glm-5" "qwen3.5-plus"; do
  curl -s -m 8 https://coding.dashscope.aliyuncs.com/apps/anthropic/v1/messages -H "x-api-key: $BAILIAN_KEY" -H "anthropic-version: 2023-06-01" -H "content-type: application/json" -d "{\"model\":\"$m\",\"max_tokens\":5,\"messages\":[{\"role\":\"user\",\"content\":\"p\"}]}" | grep -q content && echo "$m ✓" || echo "$m ✗"
done