fix(agents): correct imports and API usage for cooldown check
This commit is contained in:
parent
23f65cc90b
commit
9227026af3
@ -14,9 +14,9 @@ import {
|
|||||||
resolveModelRefFromString,
|
resolveModelRefFromString,
|
||||||
} from "./model-selection.js";
|
} from "./model-selection.js";
|
||||||
import type { FailoverReason } from "./pi-embedded-helpers.js";
|
import type { FailoverReason } from "./pi-embedded-helpers.js";
|
||||||
import { loadAuthProfileStore, isProfileInCooldown } from "./auth-profiles/usage.js";
|
import { isProfileInCooldown } from "./auth-profiles/usage.js";
|
||||||
|
import { loadAuthProfileStore } from "./auth-profiles/store.js";
|
||||||
import { resolveAuthProfileOrder } from "./auth-profiles/order.js";
|
import { resolveAuthProfileOrder } from "./auth-profiles/order.js";
|
||||||
import { getAgentAuthStoreDir } from "./agent-dirs.js";
|
|
||||||
|
|
||||||
type ModelCandidate = {
|
type ModelCandidate = {
|
||||||
provider: string;
|
provider: string;
|
||||||
@ -215,9 +215,7 @@ export async function runWithModelFallback<T>(params: {
|
|||||||
fallbacksOverride: params.fallbacksOverride,
|
fallbacksOverride: params.fallbacksOverride,
|
||||||
});
|
});
|
||||||
|
|
||||||
const authStore = params.cfg
|
const authStore = params.cfg ? loadAuthProfileStore() : null;
|
||||||
? loadAuthProfileStore(getAgentAuthStoreDir(params.cfg, "main"))
|
|
||||||
: null;
|
|
||||||
|
|
||||||
const attempts: FallbackAttempt[] = [];
|
const attempts: FallbackAttempt[] = [];
|
||||||
let lastError: unknown;
|
let lastError: unknown;
|
||||||
@ -227,7 +225,11 @@ export async function runWithModelFallback<T>(params: {
|
|||||||
|
|
||||||
// Skip candidates that are in cooldown
|
// Skip candidates that are in cooldown
|
||||||
if (authStore) {
|
if (authStore) {
|
||||||
const profileIds = resolveAuthProfileOrder(authStore, candidate.provider);
|
const profileIds = resolveAuthProfileOrder({
|
||||||
|
cfg: params.cfg,
|
||||||
|
store: authStore,
|
||||||
|
provider: candidate.provider,
|
||||||
|
});
|
||||||
const isAnyProfileAvailable = profileIds.some((id) => !isProfileInCooldown(authStore, id));
|
const isAnyProfileAvailable = profileIds.some((id) => !isProfileInCooldown(authStore, id));
|
||||||
|
|
||||||
if (profileIds.length > 0 && !isAnyProfileAvailable) {
|
if (profileIds.length > 0 && !isAnyProfileAvailable) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user