Add combo round-robin strategy to distribute load across providers (#390)

- Add comboRotationState Map to track rotation per combo
- Add getRotatedModels() to rotate model order based on strategy
- Pass comboName and comboStrategy to handleComboChat()
- Add comboStrategy setting (default: fallback)
- Add UI toggle for Combo Round Robin in profile settings

When enabled, each request to a combo starts with a different provider
instead of always starting with the first one, distributing load evenly.

Co-authored-by: Antigravity Agent <antigravity@example.com>
This commit is contained in:
bitgineer
2026-03-23 09:52:31 +07:00
committed by GitHub
co-authored by Antigravity Agent
parent 6b0cced884
commit 96f5e5c92a
4 changed files with 85 additions and 8 deletions
@@ -190,6 +190,21 @@ export default function ProfilePage() {
}
};
const updateComboStrategy = async (strategy) => {
try {
const res = await fetch("/api/settings", {
method: "PATCH",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ comboStrategy: strategy }),
});
if (res.ok) {
setSettings(prev => ({ ...prev, comboStrategy: strategy }));
}
} catch (err) {
console.error("Failed to update combo strategy:", err);
}
};
const updateStickyLimit = async (limit) => {
const numLimit = parseInt(limit);
if (isNaN(numLimit) || numLimit < 1) return;
@@ -518,6 +533,21 @@ export default function ProfilePage() {
</div>
)}
{/* Combo Round Robin */}
<div className="flex items-center justify-between pt-4 border-t border-border/50">
<div>
<p className="font-medium">Combo Round Robin</p>
<p className="text-sm text-text-muted">
Cycle through providers in combos instead of always starting with first
</p>
</div>
<Toggle
checked={settings.comboStrategy === "round-robin"}
onChange={() => updateComboStrategy(settings.comboStrategy === "round-robin" ? "fallback" : "round-robin")}
disabled={loading}
/>
</div>
<p className="text-xs text-text-muted italic pt-2 border-t border-border/50">
{settings.fallbackStrategy === "round-robin"
? `Currently distributing requests across all available accounts with ${settings.stickyRoundRobinLimit || 3} calls per account.`