fix(models): self-heal prepared auth on auth-profile failure · openclaw/openclaw@a483f70
sjf
·
2026-05-22
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -86,4 +86,5 @@ export {
|
86 | 86 | markAuthProfileFailure, |
87 | 87 | resolveProfilesUnavailableReason, |
88 | 88 | resolveProfileUnusableUntilForDisplay, |
| 89 | +setAuthProfileFailureHook, |
89 | 90 | } from "./auth-profiles/usage.js"; |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -26,6 +26,15 @@ const authProfileUsageDeps = {
|
26 | 26 | updateAuthProfileStoreWithLock, |
27 | 27 | }; |
28 | 28 | |
| 29 | +// Invoked once per recorded auth-profile failure. Gateway startup wires this |
| 30 | +// to clearCurrentProviderAuthState so the next model-listing call recomputes |
| 31 | +// against the real auth state. |
| 32 | +let onAuthProfileFailureHook: (() => void) | undefined; |
| 33 | + |
| 34 | +export function setAuthProfileFailureHook(hook: (() => void) | undefined): void { |
| 35 | +onAuthProfileFailureHook = hook; |
| 36 | +} |
| 37 | + |
29 | 38 | export const testing = { |
30 | 39 | setDepsForTest( |
31 | 40 | overrides: Partial<{ |
@@ -717,6 +726,11 @@ export async function markAuthProfileFailure(params: {
|
717 | 726 | now: updateTime, |
718 | 727 | }); |
719 | 728 | } |
| 729 | +try { |
| 730 | +onAuthProfileFailureHook?.(); |
| 731 | +} catch { |
| 732 | +// hook errors must not break failure recording |
| 733 | +} |
720 | 734 | return; |
721 | 735 | } |
722 | 736 | if (!store.profiles[profileId]) { |
@@ -758,6 +772,11 @@ export async function markAuthProfileFailure(params: {
|
758 | 772 | next: nextStats, |
759 | 773 | now, |
760 | 774 | }); |
| 775 | +try { |
| 776 | +onAuthProfileFailureHook?.(); |
| 777 | +} catch { |
| 778 | +// hook errors must not break failure recording |
| 779 | +} |
761 | 780 | } |
762 | 781 | |
763 | 782 | export async function markAuthProfileBlockedUntil(params: { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1023,7 +1023,10 @@ export async function startGatewayPostAttachRuntime(
|
1023 | 1023 | if (params.minimalTestGateway) { |
1024 | 1024 | return; |
1025 | 1025 | } |
1026 | | -const { warmCurrentProviderAuthState } = await import("../agents/model-provider-auth.js"); |
| 1026 | +const { clearCurrentProviderAuthState, warmCurrentProviderAuthState } = |
| 1027 | +await import("../agents/model-provider-auth.js"); |
| 1028 | +const { setAuthProfileFailureHook } = await import("../agents/auth-profiles.js"); |
| 1029 | +setAuthProfileFailureHook(() => clearCurrentProviderAuthState()); |
1027 | 1030 | const startMs = Date.now(); |
1028 | 1031 | await warmCurrentProviderAuthState(params.cfgAtStart); |
1029 | 1032 | params.log.info(`provider auth state pre-warmed in ${Date.now() - startMs}ms`); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。