@@ -1098,6 +1098,52 @@ describe("cron tool", () => {
10981098 } ) ;
10991099 } ) ;
11001100
1101+ it ( "recovers whitespace-padded cron add keys from local tool-call parsers" , async ( ) => {
1102+ const tool = createTestCronTool ( ) ;
1103+ await tool . execute ( "call-padded-add" , {
1104+ action : "add" ,
1105+ job : {
1106+ name : "Holiday Check-in" ,
1107+ description : "Casual check-in while on holiday, 2x per day" ,
1108+ "schedule " : { kind : "cron" , expr : "30 10,20 * * *" , tz : "Europe/Madrid" } ,
1109+ "sessionTarget " : "isolated" ,
1110+ "payload " : { kind : "agentTurn" , message : "Holiday check-in." } ,
1111+ "enabled " : true ,
1112+ } ,
1113+ } ) ;
1114+
1115+ const params = expectSingleGatewayCallMethod ( "cron.add" ) as Record < string , unknown > ;
1116+ expect ( Object . keys ( params ) . every ( ( key ) => key === key . trim ( ) ) ) . toBe ( true ) ;
1117+ expect ( params ) . toMatchObject ( {
1118+ name : "Holiday Check-in" ,
1119+ description : "Casual check-in while on holiday, 2x per day" ,
1120+ schedule : { kind : "cron" , expr : "30 10,20 * * *" , tz : "Europe/Madrid" } ,
1121+ sessionTarget : "isolated" ,
1122+ payload : { kind : "agentTurn" , message : "Holiday check-in." } ,
1123+ enabled : true ,
1124+ } ) ;
1125+ } ) ;
1126+
1127+ it ( "keeps a padded duplicate key when the canonical cron key already exists" , async ( ) => {
1128+ const tool = createTestCronTool ( ) ;
1129+ await tool . execute ( "call-padded-duplicate-add" , {
1130+ action : "add" ,
1131+ job : {
1132+ name : "dup" ,
1133+ schedule : { kind : "cron" , expr : "0 9 * * *" } ,
1134+ "enabled " : true ,
1135+ enabled : false ,
1136+ payload : { kind : "agentTurn" , message : "dup test" } ,
1137+ } ,
1138+ } ) ;
1139+
1140+ // Genuine duplicates are not silently merged: the padded key survives so
1141+ // strict gateway validation surfaces the conflict instead of guessing.
1142+ const params = expectSingleGatewayCallMethod ( "cron.add" ) as Record < string , unknown > ;
1143+ expect ( params . enabled ) . toBe ( false ) ;
1144+ expect ( params [ "enabled " ] ) . toBe ( true ) ;
1145+ } ) ;
1146+
11011147 it ( "stamps cron.add with caller sessionKey when missing" , async ( ) => {
11021148 callGatewayMock . mockResolvedValueOnce ( { ok : true } ) ;
11031149
0 commit comments