@@ -1409,6 +1409,55 @@ describe("sessions tools", () => {
14091409 } ) ;
14101410 } ) ;
14111411
1412+ it ( "sessions_send preserves active delivery when transcript commit wait is unsupported" , async ( ) => {
1413+ const calls : Array < { method ?: string } > = [ ] ;
1414+ const runScopedCallerKey = "agent:leasing-ops:cron:monthly-utility:run:run-fast" ;
1415+ const queueMessage = vi . fn ( async ( ) => { } ) ;
1416+ setActiveEmbeddedRun (
1417+ "caller-active-session" ,
1418+ {
1419+ queueMessage,
1420+ isStreaming : ( ) => true ,
1421+ isCompacting : ( ) => false ,
1422+ abort : ( ) => { } ,
1423+ } ,
1424+ runScopedCallerKey ,
1425+ ) ;
1426+ callGatewayMock . mockImplementation ( async ( opts : unknown ) => {
1427+ const request = opts as { method ?: string } ;
1428+ calls . push ( request ) ;
1429+ if ( request . method === "agent" ) {
1430+ throw new Error ( "fallback agent should not start" ) ;
1431+ }
1432+ return { } ;
1433+ } ) ;
1434+
1435+ const tool = createOpenClawTools ( {
1436+ agentSessionKey : "agent:re-portal:main" ,
1437+ agentChannel : "telegram" ,
1438+ } ) . find ( ( candidate ) => candidate . name === "sessions_send" ) ;
1439+ if ( ! tool ) {
1440+ throw new Error ( "missing sessions_send tool" ) ;
1441+ }
1442+
1443+ const result = await tool . execute ( "call-run-scoped-caller" , {
1444+ sessionKey : runScopedCallerKey ,
1445+ message : "[TASK-COMPLETE] re-portal occupancy ready" ,
1446+ timeoutSeconds : 0 ,
1447+ } ) ;
1448+
1449+ const details = sessionsSendDetails ( result . details ) ;
1450+ expect ( details . status ) . toBe ( "accepted" ) ;
1451+ expect ( details . sessionKey ) . toBe ( runScopedCallerKey ) ;
1452+ expect ( queueMessage ) . toHaveBeenCalledOnce ( ) ;
1453+ expect ( queueMessage ) . toHaveBeenCalledWith ( expect . stringContaining ( "[Inter-session message]" ) , {
1454+ steeringMode : "all" ,
1455+ debounceMs : 0 ,
1456+ deliveryTimeoutMs : 30_000 ,
1457+ } ) ;
1458+ expect ( calls . some ( ( call ) => call . method === "agent" ) ) . toBe ( false ) ;
1459+ } ) ;
1460+
14121461 it ( "sessions_send reports run-scoped fallback admission failures" , async ( ) => {
14131462 const runScopedCallerKey = "agent:leasing-ops:cron:monthly-utility:run:run-fast" ;
14141463 const queueMessage = vi . fn ( async ( ) => {
0 commit comments