mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 09:17:38 +00:00
Agents: infer auth-profile unavailable failover reason
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
markAuthProfileFailure,
|
||||
markAuthProfileGood,
|
||||
markAuthProfileUsed,
|
||||
resolveProfilesUnavailableReason,
|
||||
} from "../auth-profiles.js";
|
||||
import {
|
||||
CONTEXT_WINDOW_HARD_MIN_TOKENS,
|
||||
@@ -364,9 +365,18 @@ export async function runEmbeddedPiAgent(
|
||||
const resolveAuthProfileFailoverReason = (params: {
|
||||
allInCooldown: boolean;
|
||||
message: string;
|
||||
profileIds?: Array<string | undefined>;
|
||||
}): FailoverReason => {
|
||||
if (params.allInCooldown) {
|
||||
return "rate_limit";
|
||||
const profileIds = (params.profileIds ?? profileCandidates).filter(
|
||||
(id): id is string => typeof id === "string" && id.length > 0,
|
||||
);
|
||||
return (
|
||||
resolveProfilesUnavailableReason({
|
||||
store: authStore,
|
||||
profileIds,
|
||||
}) ?? "rate_limit"
|
||||
);
|
||||
}
|
||||
const classified = classifyFailoverReason(params.message);
|
||||
return classified ?? "auth";
|
||||
@@ -385,6 +395,7 @@ export async function runEmbeddedPiAgent(
|
||||
const reason = resolveAuthProfileFailoverReason({
|
||||
allInCooldown: params.allInCooldown,
|
||||
message,
|
||||
profileIds: profileCandidates,
|
||||
});
|
||||
if (fallbackConfigured) {
|
||||
throw new FailoverError(message, {
|
||||
|
||||
Reference in New Issue
Block a user