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 →
debatepreset - Writing content for publishing →
best_of_npreset - Reviewing code or technical artifacts →
verifypreset - 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)
| # | Model | Lab | Gateway | Model ID | Strengths |
|---|---|---|---|---|---|
| 0 | Claude Opus 4.6 | Anthropic | Current session | — | Orchestrator. Synthesizes, arbitrates, final judge. |
| 1 | Claude Opus 4.6 | Anthropic | Zenmux | anthropic/claude-opus-4.6 | Fresh-context Opus as independent reviewer |
| 2 | Grok 4 | xAI | Zenmux | x-ai/grok-4 | Strong reasoning, unconventional angles |
| 3 | Gemini 3.1 Pro | Zenmux | google/gemini-3.1-pro-preview | Long context, web-grounded, multimodal | |
| 4 | MiMo V2 Pro | Xiaomi | Zenmux | xiaomi/mimo-v2-pro | MoE reasoning, thinking model |
| 5 | Kimi K2.5 | Moonshot | Zenmux | moonshotai/kimi-k2.5 | Strong Chinese, long context, detail-oriented |
| 6 | MiniMax M2.7 | MiniMax | Zenmux | minimax/minimax-m2.7-highspeed | Fast, thinking model |
| 7 | GLM-5 | Zhipu AI | 百炼 | glm-5 | Fast MoE, constraint analysis |
| 8 | Qwen-3.5-Plus | Alibaba | 百炼 | qwen3.5-plus | Strong 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 -pestrip is mandatory — thinking models (MiMo, MiniMax, Kimi) emit control chars- Thinking models (MiMo, MiniMax) return
thinkingblocks beforetextblocks — the parser above already handles this by filtering fortype == 'text' - Use
max_tokens: 4096for cloud models (enough for detailed review, not wasteful) - Timeout 120s per model — some thinking models need time
Dispatch Table (copy-paste ready)
| Tag | Gateway | KEY var | MODEL_ID |
|---|---|---|---|
opus2 | Zenmux | ZENMUX_KEY | anthropic/claude-opus-4.6 |
grok | Zenmux | ZENMUX_KEY | x-ai/grok-4 |
gemini | Zenmux | ZENMUX_KEY | google/gemini-3.1-pro-preview |
mimo | Zenmux | ZENMUX_KEY | xiaomi/mimo-v2-pro |
kimi | Zenmux | ZENMUX_KEY | moonshotai/kimi-k2.5 |
minimax | Zenmux | ZENMUX_KEY | minimax/minimax-m2.7-highspeed |
glm5 | 百炼 | BAILIAN_KEY | glm-5 |
qwen | 百炼 | BAILIAN_KEY | qwen3.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)
| # | Model | Role | Focus |
|---|---|---|---|
| 1 | Claude Opus (Zenmux) | Lead Reviewer | Architecture, design patterns, code quality |
| 2 | Grok 4 | Devil's Advocate | Challenge assumptions, unconventional critique |
| 3 | Gemini 3.1 Pro | Security & Perf Auditor | XSS, injection, perf, scalability |
| 4 | MiMo V2 Pro | Logic Verifier | Reasoning correctness, edge cases |
| 5 | Kimi K2.5 | UX & Readability Critic | User experience, naming, clarity |
| 6 | MiniMax M2.7 | Completeness Auditor | Missing features, gaps vs requirements |
| 7 | GLM-5 | Constraint Checker | API contracts, error handling, robustness |
| 8 | Qwen-3.5-Plus | Counterexample Hunter | What could go wrong? Adversarial inputs |
debate preset (spec/design)
| # | Model | Role | Focus |
|---|---|---|---|
| 1 | Claude Opus (Zenmux) | Proposer A | Full proposal with implementation detail |
| 2 | Grok 4 | Red Team | Attack proposals, find fatal flaws |
| 3 | Gemini 3.1 Pro | Proposer B | Alternative approach, different trade-offs |
| 4 | MiMo V2 Pro | Feasibility Analyst | Can this actually work? Engineering reality check |
| 5 | Kimi K2.5 | User Advocate | End-user perspective, usability |
| 6 | MiniMax M2.7 | Scope Guardian | Scope creep detection, YAGNI enforcement |
| 7 | GLM-5 | Constraint Auditor | Risks, dependencies, constraints |
| 8 | Qwen-3.5-Plus | Counter-Proposer | Challenge assumptions, counter-proposal |
best_of_n preset (content)
| # | Model | Role | Focus |
|---|---|---|---|
| 1-3 | Opus, Gemini, Kimi | Drafters | Each writes a full draft |
| 4-5 | Grok, MiMo | Critics | Rate and critique all drafts |
| 6-8 | MiniMax, GLM, Qwen | Judges | Pick 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
| Stakes | Quorum | Deadline | Extra |
|---|---|---|---|
| High (external publish, key design) | 6/8 | 120s | + mandatory critique round |
| Medium (specs, internal docs) | 5/8 | 90s | critique optional |
| Low (drafts, notes) | 3/8 | 60s | single round |
Degradation Policy
| Available | Behavior |
|---|---|
| 7-8 models | Full Orchestra |
| 5-6 models | Standard — solid |
| 3-4 models | Reduced — [REDUCED] marker |
| 1-2 models | Minimal — flag for human review |
| 0 models | Degraded — CC solo, [DEGRADED] marker |
Error Handling
| Error Class | Detection | Action |
|---|---|---|
| auth_error | HTTP 401/403 | No retry. Degrade. |
| transport_error | Connection reset, 5xx | Retry once, 3s backoff. |
| timeout_error | >120s | Mark timeout, continue. |
| parse_error | JSON failure | Preserve raw. Fallback parse. Drop if fails. |
| thinking_only | Response has thinking blocks but no text block | Retry with max_tokens: 8192 (thinking models need more budget) |
| empty_text | Text block exists but empty | Drop, 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 -pecontrol 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_tokensfor 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