@@ -1212,6 +1212,76 @@ describe("runCronIsolatedAgentTurn message tool policy", () => {
12121212 } ) ;
12131213 } ) ;
12141214
1215+ it ( "keeps the isolated run successful when post-run delivery fails" , async ( ) => {
1216+ mockRunCronFallbackPassthrough ( ) ;
1217+ resolveCronDeliveryPlanMock . mockReturnValue ( makeAnnounceDeliveryPlan ( ) ) ;
1218+ resolveCronPayloadOutcomeMock . mockReturnValue ( {
1219+ summary : "Final cron report" ,
1220+ outputText : "Final cron report" ,
1221+ synthesizedText : "Final cron report" ,
1222+ deliveryPayload : { text : "Final cron report" } ,
1223+ deliveryPayloads : [ { text : "Final cron report" } ] ,
1224+ deliveryPayloadHasStructuredContent : false ,
1225+ hasFatalErrorPayload : false ,
1226+ hasFatalStructuredErrorPayload : false ,
1227+ embeddedRunError : undefined ,
1228+ } ) ;
1229+ dispatchCronDeliveryMock . mockImplementationOnce (
1230+ ( params : {
1231+ withRunSession : ( result : {
1232+ status : "error" ;
1233+ summary : string ;
1234+ outputText : string ;
1235+ error : string ;
1236+ deliveryAttempted : true ;
1237+ } ) => unknown ;
1238+ } ) => ( {
1239+ result : params . withRunSession ( {
1240+ status : "error" ,
1241+ summary : "Final cron report" ,
1242+ outputText : "Final cron report" ,
1243+ error : "Message failed" ,
1244+ deliveryAttempted : true ,
1245+ } ) ,
1246+ delivered : false ,
1247+ deliveryAttempted : true ,
1248+ summary : "Final cron report" ,
1249+ outputText : "Final cron report" ,
1250+ synthesizedText : "Final cron report" ,
1251+ deliveryPayloads : [ { text : "Final cron report" } ] ,
1252+ } ) ,
1253+ ) ;
1254+
1255+ const result = await runCronIsolatedAgentTurn ( {
1256+ ...makeParams ( ) ,
1257+ job : makeAnnounceMessageToolJob ( {
1258+ id : "delivery-failure-after-success" ,
1259+ name : "Delivery Failure After Success" ,
1260+ } ) ,
1261+ } ) ;
1262+
1263+ expect ( result . status ) . toBe ( "ok" ) ;
1264+ expect ( result . error ) . toBe ( "Message failed" ) ;
1265+ expect ( result . delivered ) . toBe ( false ) ;
1266+ expect ( result . deliveryAttempted ) . toBe ( true ) ;
1267+ expectDeliveryFields ( result . delivery , {
1268+ intended : { channel : "messagechat" , to : "123" , source : "explicit" } ,
1269+ resolved : { ok : true , channel : "messagechat" , to : "123" , source : "explicit" } ,
1270+ fallbackUsed : true ,
1271+ delivered : false ,
1272+ } ) ;
1273+ expect ( result . diagnostics ?. summary ) . toBe ( "Message failed" ) ;
1274+ expect ( result . diagnostics ?. entries ) . toEqual (
1275+ expect . arrayContaining ( [
1276+ expect . objectContaining ( {
1277+ source : "delivery" ,
1278+ severity : "error" ,
1279+ message : "Message failed" ,
1280+ } ) ,
1281+ ] ) ,
1282+ ) ;
1283+ } ) ;
1284+
12151285 it ( "rewrites generic message provider to resolved channel in delivery trace" , async ( ) => {
12161286 mockRunCronFallbackPassthrough ( ) ;
12171287 resolveCronDeliveryPlanMock . mockReturnValue ( makeAnnounceDeliveryPlan ( ) ) ;
0 commit comments