@@ -37,9 +37,7 @@ import {
3737 hasNonzeroUsage ,
3838 isCliProvider ,
3939 isExternalHookSession ,
40- loadModelCatalog ,
4140 logWarn ,
42- lookupContextTokens ,
4341 mapHookExternalContentSource ,
4442 normalizeAgentId ,
4543 normalizeThinkLevel ,
@@ -66,6 +64,10 @@ let sessionStoreRuntimePromise:
6664let cronAuthProfileRuntimePromise :
6765 | Promise < typeof import ( "./run-auth-profile.runtime.js" ) >
6866 | undefined ;
67+ let cronContextRuntimePromise : Promise < typeof import ( "./run-context.runtime.js" ) > | undefined ;
68+ let cronModelCatalogRuntimePromise :
69+ | Promise < typeof import ( "./run-model-catalog.runtime.js" ) >
70+ | undefined ;
6971
7072async function loadSessionStoreRuntime ( ) {
7173 sessionStoreRuntimePromise ??= import ( "../../config/sessions/store.runtime.js" ) ;
@@ -77,6 +79,16 @@ async function loadCronAuthProfileRuntime() {
7779 return await cronAuthProfileRuntimePromise ;
7880}
7981
82+ async function loadCronContextRuntime ( ) {
83+ cronContextRuntimePromise ??= import ( "./run-context.runtime.js" ) ;
84+ return await cronContextRuntimePromise ;
85+ }
86+
87+ async function loadCronModelCatalogRuntime ( ) {
88+ cronModelCatalogRuntimePromise ??= import ( "./run-model-catalog.runtime.js" ) ;
89+ return await cronModelCatalogRuntimePromise ;
90+ }
91+
8092function hasConfiguredAuthProfiles ( cfg : OpenClawConfig ) : boolean {
8193 return (
8294 Boolean ( cfg . auth ?. profiles && Object . keys ( cfg . auth . profiles ) . length > 0 ) ||
@@ -91,6 +103,7 @@ function resolveNonNegativeNumber(value: number | undefined): number | undefined
91103export type { RunCronAgentTurnResult } from "./run.types.js" ;
92104
93105type ResolvedCronDeliveryTarget = Awaited < ReturnType < typeof resolveDeliveryTarget > > ;
106+ type CronModelCatalogRuntime = typeof import ( "./run-model-catalog.runtime.js" ) ;
94107
95108type IsolatedDeliveryContract = "cron-owned" | "shared" ;
96109
@@ -250,10 +263,14 @@ async function prepareCronRunContext(params: {
250263 ...input . cfg ,
251264 agents : Object . assign ( { } , input . cfg . agents , { defaults : agentCfg } ) ,
252265 } ;
253- let catalog : Awaited < ReturnType < typeof loadModelCatalog > > | undefined ;
266+ let catalog : Awaited < ReturnType < CronModelCatalogRuntime [ " loadModelCatalog" ] > > | undefined ;
254267 const loadCatalog = async ( ) => {
255268 if ( ! catalog ) {
256- catalog = await loadModelCatalog ( { config : cfgWithAgentDefaults } ) ;
269+ catalog = await (
270+ await loadCronModelCatalogRuntime ( )
271+ ) . loadModelCatalog ( {
272+ config : cfgWithAgentDefaults ,
273+ } ) ;
257274 }
258275 return catalog ;
259276 } ;
@@ -511,7 +528,9 @@ async function finalizeCronRun(params: {
511528 execution . liveSelection . provider ;
512529 const contextTokens =
513530 resolvePositiveContextTokens ( prepared . agentCfg ?. contextTokens ) ??
514- lookupContextTokens ( modelUsed , { allowAsyncLoad : false } ) ??
531+ ( await loadCronContextRuntime ( ) ) . lookupContextTokens ( modelUsed , {
532+ allowAsyncLoad : false ,
533+ } ) ??
515534 resolvePositiveContextTokens ( prepared . cronSession . sessionEntry . contextTokens ) ??
516535 DEFAULT_CONTEXT_TOKENS ;
517536
0 commit comments