fix: lint curly braces + thread modelId into embedded runner cooldown checks

- 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
This commit is contained in:
kiranvk2011 2026-03-18 15:03:38 +00:00
parent 75661f59c1
commit d88de88962
3 changed files with 19 additions and 7 deletions

View File

@ -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
}

View File

@ -801,7 +801,9 @@ export async function runWithModelFallback<T>(params: {
attempt.reason ? ` (${attempt.reason})` : ""
}`,
soonestCooldownExpiry: (() => {
if (!authStore) return null;
if (!authStore) {
return null;
}
const allProfileIds = new Set<string>();
for (const c of candidates) {
const ids = resolveAuthProfileOrder({
@ -809,7 +811,9 @@ export async function runWithModelFallback<T>(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]);
})(),

View File

@ -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;