design-docs/variant-system.md
The variant system generates multiple code options in parallel, allowing users to compare different AI-generated implementations. The system defaults to 3 variants and scales automatically by changing NUM_VARIANTS in config.
Key Setting: NUM_VARIANTS = 3 in backend/config.py
Changing this value automatically scales the entire system to support any number of variants.
Models cycle based on available API keys:
# Both API keys present
models = [claude_model, Llm.GPT_4_1_NANO_2025_04_14]
# Claude only
models = [claude_model, Llm.CLAUDE_4_5_SONNET_2025_09_29]
# OpenAI only
models = [Llm.GPT_4O_2024_11_20]
Cycling: If models = [A, B] and NUM_VARIANTS = 5, result is [A, B, A, B, A]
Generation Type:
event.code for cross-platform compatibilityStatusBroadcastMiddleware sends variantCount to frontendModelSelectionStage cycles through available modelsresizeVariants() adapts UI to backend count"variantCount" | "chunk" | "status" | "setCode" | "variantComplete" | "variantError"
✅ Scalable: Change NUM_VARIANTS and everything adapts
✅ Cross-platform: Keyboard shortcuts work Mac/Windows
✅ Responsive: Grid layouts adapt to count
✅ Simple: Model cycling handles any variant count
backend/config.py - NUM_VARIANTS settingbackend/routes/generate_code.py - Model selection pipelinefrontend/src/components/variants/Variants.tsx - UI and shortcutsfrontend/src/store/project-store.ts - State management