@@ -36,6 +36,7 @@ const AGENT_RUNTIME_PLUGIN_PREWARM_START_DELAY_MS = 10_000;
3636const DEFERRED_SIDECAR_START_DELAY_MS = 100 ;
3737const SESSION_LOCK_CLEANUP_CONCURRENCY = 4 ;
3838const SKIP_STARTUP_MODEL_PREWARM_ENV = "OPENCLAW_SKIP_STARTUP_MODEL_PREWARM" ;
39+ const SKIP_PROVIDER_AUTH_PREWARM_ENV = "OPENCLAW_SKIP_PROVIDER_AUTH_PREWARM" ;
3940const QMD_STARTUP_IDLE_DELAY_MS = 120_000 ;
4041
4142type Awaitable < T > = T | Promise < T > ;
@@ -128,6 +129,12 @@ function shouldSkipStartupModelPrewarm(env: NodeJS.ProcessEnv = process.env): bo
128129 return raw === "1" || raw === "true" || raw === "yes" || raw === "on" ;
129130}
130131
132+ export function shouldSkipProviderAuthStartupPrewarm (
133+ env : NodeJS . ProcessEnv = process . env ,
134+ ) : boolean {
135+ return isTruthyEnvValue ( env [ SKIP_PROVIDER_AUTH_PREWARM_ENV ] ) ;
136+ }
137+
131138function resolveGatewayMemoryStartupPolicy ( cfg : OpenClawConfig ) : GatewayMemoryStartupPolicy {
132139 if ( cfg . memory ?. backend !== "qmd" ) {
133140 return { mode : "off" } ;
@@ -200,6 +207,7 @@ function scheduleProviderAuthStatePrewarm(params: {
200207 warn : ( msg : string ) => void ;
201208 } ;
202209 delayMs ?: number ;
210+ startupEnabled ?: boolean ;
203211} ) : GatewayPostReadySidecarHandle {
204212 let stopped = false ;
205213 let startupTimer : ReturnType < typeof setTimeout > | undefined ;
@@ -270,6 +278,9 @@ function scheduleProviderAuthStatePrewarm(params: {
270278 clearCurrentProviderAuthState ( ) ;
271279 scheduleAuthMapRewarm ( "auth-profile-failure" ) ;
272280 } ) ;
281+ if ( params . startupEnabled === false ) {
282+ return ;
283+ }
273284 startupTimer = setTimeout (
274285 ( ) => {
275286 void ( async ( ) => {
@@ -1109,6 +1120,7 @@ export async function startGatewayPostAttachRuntime(
11091120 logReadyOnSidecars ?: boolean ;
11101121 providerAuthPrewarm ?: {
11111122 enabled ?: boolean ;
1123+ startupEnabled ?: boolean ;
11121124 delayMs ?: number ;
11131125 getConfig ?: ( ) => OpenClawConfig ;
11141126 } ;
@@ -1288,6 +1300,7 @@ export async function startGatewayPostAttachRuntime(
12881300 getConfig : params . providerAuthPrewarm ?. getConfig ?? ( ( ) => params . cfgAtStart ) ,
12891301 log : params . log ,
12901302 delayMs : params . providerAuthPrewarm ?. delayMs ,
1303+ startupEnabled : params . providerAuthPrewarm ?. startupEnabled ,
12911304 } ) ,
12921305 ) ;
12931306 }
@@ -1391,6 +1404,7 @@ export const testing = {
13911404 cleanupStaleSessionLocks,
13921405 scheduleProviderAuthStatePrewarm,
13931406 schedulePrimaryModelPrewarm,
1407+ shouldSkipProviderAuthStartupPrewarm,
13941408 shouldSkipStartupModelPrewarm,
13951409 stopPostReadySidecarsAfterCloseStarted,
13961410} ;
0 commit comments