File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -229,18 +229,19 @@ export function canPrewarmCombinedSessionStoresForGateway(
229229 cfg : OpenClawConfig ,
230230 params : { agentIds : readonly string [ ] ; maxRows : number } ,
231231) : boolean {
232- const resolvedTargets = params . agentIds . flatMap ( ( agentId ) => {
233- const resolved = resolveGatewaySessionStoreTargets ( cfg , { agentId } ) ;
234- return [ ...resolved . durableTargets , ...resolved . incognitoTargets ] ;
235- } ) ;
236- const targets = dedupeSessionStoreTargetsBySqliteTarget ( resolvedTargets , {
237- defaultAgentId : normalizeAgentId ( resolveDefaultAgentId ( cfg ) ) ,
238- } ) ;
232+ const defaultAgentId = normalizeAgentId ( resolveDefaultAgentId ( cfg ) ) ;
239233 let totalRows = 0 ;
240- for ( const target of targets ) {
241- totalRows += countSessionEntryRowsReadOnly ( target ) ;
242- if ( totalRows > params . maxRows ) {
243- return false ;
234+ for ( const agentId of params . agentIds ) {
235+ const resolved = resolveGatewaySessionStoreTargets ( cfg , { agentId } ) ;
236+ const projectionTargets = dedupeSessionStoreTargetsBySqliteTarget (
237+ [ ...resolved . durableTargets , ...resolved . incognitoTargets ] ,
238+ { defaultAgentId } ,
239+ ) ;
240+ for ( const target of projectionTargets ) {
241+ totalRows += countSessionEntryRowsReadOnly ( target ) ;
242+ if ( totalRows > params . maxRows ) {
243+ return false ;
244+ }
244245 }
245246 }
246247 return true ;
Original file line number Diff line number Diff line change @@ -1408,6 +1408,13 @@ describe("loadCombinedSessionStoreForGateway includes disk-only agents (#32804)"
14081408 "main" ,
14091409 ) ;
14101410
1411+ expect (
1412+ canPrewarmCombinedSessionStoresForGateway ( cfg , {
1413+ agentIds : [ "main" , "ops" ] ,
1414+ maxRows : 1 ,
1415+ } ) ,
1416+ ) . toBe ( false ) ;
1417+
14111418 const { diagnostics, store } = loadCombinedSessionStoreForGateway ( cfg ) ;
14121419 expect ( store [ "agent:main:main" ] ?. sessionId ) . toBe ( "s-main-unscoped" ) ;
14131420 expect ( store [ "agent:ops:main" ] ) . toBeUndefined ( ) ;
You can’t perform that action at this time.
0 commit comments