Heaven K Claude Opus 4.6 commited on
Commit
c440d28
·
1 Parent(s): c3c045d

fix: force pool to always prefer primary provider (Mistral first)

Browse files

findAvailableSlot now always scans from index 0 instead of
drifting with currentIndex, ensuring Mistral is always tried
first before falling back to Groq.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

packages/server/src/providers/pool.ts CHANGED
@@ -47,12 +47,11 @@ export class AIProviderPool {
47
  private findAvailableSlot(): ProviderSlot | null {
48
  const now = Date.now();
49
 
50
- // First pass: find any slot that's ready
51
  for (let i = 0; i < this.slots.length; i++) {
52
- const idx = (this.currentIndex + i) % this.slots.length;
53
- const slot = this.slots[idx];
54
  if (!slot.disabled && now >= slot.cooldownUntil && slot.dailyRequests < slot.dailyLimit) {
55
- this.currentIndex = idx;
56
  return slot;
57
  }
58
  }
 
47
  private findAvailableSlot(): ProviderSlot | null {
48
  const now = Date.now();
49
 
50
+ // Always start from slot 0 (primary provider) to enforce priority ordering
51
  for (let i = 0; i < this.slots.length; i++) {
52
+ const slot = this.slots[i];
 
53
  if (!slot.disabled && now >= slot.cooldownUntil && slot.dailyRequests < slot.dailyLimit) {
54
+ this.currentIndex = i;
55
  return slot;
56
  }
57
  }