@@ -378,6 +378,34 @@ describe("image generation task status", () => {
378378 ) . toBeUndefined ( ) ;
379379 } ) ;
380380
381+ it ( "does not keep stale recent starts forever for non-finite maxAgeMs" , ( ) => {
382+ const now = Date . now ( ) ;
383+ recordRecentMediaGenerationTaskStartForSession ( {
384+ sessionKey : "agent:main" ,
385+ taskKind : IMAGE_GENERATION_TASK_KIND ,
386+ sourcePrefix : "image_generate" ,
387+ taskId : "task-stale" ,
388+ runId : "run-stale" ,
389+ taskLabel : "stale prompt" ,
390+ requestKey : "image-request:stale" ,
391+ providerId : "xai" ,
392+ progressSummary : "Generating stale image" ,
393+ nowMs : now - 1 ,
394+ } ) ;
395+
396+ expect (
397+ findRecentStartedMediaGenerationTaskForSession ( {
398+ sessionKey : "agent:main" ,
399+ taskKind : IMAGE_GENERATION_TASK_KIND ,
400+ sourcePrefix : "image_generate" ,
401+ taskLabel : "stale prompt" ,
402+ requestKey : "image-request:stale" ,
403+ maxAgeMs : Number . POSITIVE_INFINITY ,
404+ nowMs : now ,
405+ } ) ,
406+ ) . toBeUndefined ( ) ;
407+ } ) ;
408+
381409 it ( "does not block a distinct prompt from a cached active recent start" , ( ) => {
382410 recordRecentMediaGenerationTaskStartForSession ( {
383411 sessionKey : "agent:main" ,
0 commit comments