From d88de88962e268464b966f9f52befa26317f0ee2 Mon Sep 17 00:00:00 2001 From: kiranvk2011 Date: Wed, 18 Mar 2026 15:03:38 +0000 Subject: [PATCH] fix: lint curly braces + thread modelId into embedded runner cooldown checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add curly braces to single-line if/for bodies in usage.ts and model-fallback.ts to satisfy oxlint eslint(curly) rule - Thread modelId into all 3 isProfileInCooldown calls in pi-embedded-runner/run.ts (lines 719, 746, 767) so the inner profile loop respects per-model cooldown scope — fixes Codex P1 review comment about outer gate passing model-B while inner loop rejects it without model context --- src/agents/auth-profiles/usage.ts | 8 ++++++-- src/agents/model-fallback.ts | 8 ++++++-- src/agents/pi-embedded-runner/run.ts | 10 +++++++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/agents/auth-profiles/usage.ts b/src/agents/auth-profiles/usage.ts index 4412e03ec27..f9b7cfc975f 100644 --- a/src/agents/auth-profiles/usage.ts +++ b/src/agents/auth-profiles/usage.ts @@ -291,8 +291,12 @@ export async function markAuthProfileUsed(params: { export function calculateAuthProfileCooldownMs(errorCount: number): number { const normalized = Math.max(1, errorCount); - if (normalized <= 1) return 30_000; // 30 seconds - if (normalized <= 2) return 60_000; // 1 minute + if (normalized <= 1) { + return 30_000; // 30 seconds + } + if (normalized <= 2) { + return 60_000; // 1 minute + } return 5 * 60_000; // 5 minutes max } diff --git a/src/agents/model-fallback.ts b/src/agents/model-fallback.ts index 7223c6c9dfa..ece9d59334c 100644 --- a/src/agents/model-fallback.ts +++ b/src/agents/model-fallback.ts @@ -801,7 +801,9 @@ export async function runWithModelFallback(params: { attempt.reason ? ` (${attempt.reason})` : "" }`, soonestCooldownExpiry: (() => { - if (!authStore) return null; + if (!authStore) { + return null; + } const allProfileIds = new Set(); for (const c of candidates) { const ids = resolveAuthProfileOrder({ @@ -809,7 +811,9 @@ export async function runWithModelFallback(params: { store: authStore, provider: c.provider, }); - for (const id of ids) allProfileIds.add(id); + for (const id of ids) { + allProfileIds.add(id); + } } return getSoonestCooldownExpiry(authStore, [...allProfileIds]); })(), diff --git a/src/agents/pi-embedded-runner/run.ts b/src/agents/pi-embedded-runner/run.ts index b5c55cf9d6d..00159222af0 100644 --- a/src/agents/pi-embedded-runner/run.ts +++ b/src/agents/pi-embedded-runner/run.ts @@ -716,7 +716,7 @@ export async function runEmbeddedPiAgent( let nextIndex = profileIndex + 1; while (nextIndex < profileCandidates.length) { const candidate = profileCandidates[nextIndex]; - if (candidate && isProfileInCooldown(authStore, candidate)) { + if (candidate && isProfileInCooldown(authStore, candidate, undefined, modelId)) { nextIndex += 1; continue; } @@ -743,7 +743,9 @@ export async function runEmbeddedPiAgent( ); const allAutoProfilesInCooldown = autoProfileCandidates.length > 0 && - autoProfileCandidates.every((candidate) => isProfileInCooldown(authStore, candidate)); + autoProfileCandidates.every((candidate) => + isProfileInCooldown(authStore, candidate, undefined, modelId), + ); const unavailableReason = allAutoProfilesInCooldown ? (resolveProfilesUnavailableReason({ store: authStore, @@ -762,7 +764,9 @@ export async function runEmbeddedPiAgent( while (profileIndex < profileCandidates.length) { const candidate = profileCandidates[profileIndex]; const inCooldown = - candidate && candidate !== lockedProfileId && isProfileInCooldown(authStore, candidate); + candidate && + candidate !== lockedProfileId && + isProfileInCooldown(authStore, candidate, undefined, modelId); if (inCooldown) { if (allowTransientCooldownProbe && !didTransientCooldownProbe) { didTransientCooldownProbe = true;