@@ -649,7 +649,8 @@ describe("heartbeat piggybacking for coordinated apps", () => {
649649 expect ( appRes . status ) . toBe ( 200 ) ;
650650 expect ( appRes . body . availability ) . toBe ( "available" ) ;
651651 expect ( appRes . body . tasksCompleted ) . toBe ( 3 ) ;
652- expect ( appRes . body . totalInteractions ) . toBe ( 3 ) ;
652+ // totalInteractions is tracked independently via appInteractions, not piggybacked
653+ expect ( appRes . body . totalInteractions ) . toBe ( 0 ) ;
653654 } ) ;
654655
655656 it ( "does not piggyback on unrelated agent heartbeat" , async ( ) => {
@@ -807,19 +808,23 @@ describe("GET /apps/search?sortBy=interactions", () => {
807808 } ) ,
808809 } ) ;
809810
810- // Send heartbeat with high interaction count
811+ // Send heartbeat with appInteractions to increment the app's total_interactions
811812 const payload = await signedHeartbeat ( {
812813 address : highAddr ,
813814 _account : highInteractionAccount ,
814- telemetry : { tasksCompleted : 50 , tasksFailed : 5 } ,
815+ telemetry : {
816+ tasksCompleted : 50 ,
817+ tasksFailed : 5 ,
818+ appInteractions : { "high-interact-app" : 55 } ,
819+ } ,
815820 } ) ;
816821 await request . post ( "/agents/heartbeat" ) . send ( payload ) ;
817822
818823 const res = await request . get ( "/apps/search?sortBy=interactions" ) ;
819824 expect ( res . status ) . toBe ( 200 ) ;
820825 expect ( res . body . apps . length ) . toBeGreaterThan ( 0 ) ;
821826
822- // high-interact-app should be first since it has 55 interactions
827+ // high-interact-app should be first since it has 55 interactions via appInteractions
823828 expect ( res . body . apps [ 0 ] . appId ) . toBe ( "high-interact-app" ) ;
824829 } ) ;
825830} ) ;
0 commit comments