@@ -266,6 +266,8 @@ export namespace SessionPrompt {
266266 using _ = defer ( ( ) => cancel ( sessionID ) )
267267
268268 let step = 0
269+ let sessionAgent : string | undefined
270+ let sessionModel : { providerID : string ; modelID : string } | undefined
269271 const session = await Session . get ( sessionID )
270272 while ( true ) {
271273 SessionStatus . set ( sessionID , { type : "busy" } )
@@ -291,6 +293,8 @@ export namespace SessionPrompt {
291293 }
292294
293295 if ( ! lastUser ) throw new Error ( "No user message found in stream. This should never happen." )
296+ sessionAgent = lastUser . agent
297+ sessionModel = lastUser . model
294298 if (
295299 lastAssistant ?. finish &&
296300 ! [ "tool-calls" , "unknown" ] . includes ( lastAssistant . finish ) &&
@@ -626,13 +630,19 @@ export namespace SessionPrompt {
626630 // Allow plugins to optionally resume this session before it completes
627631 const sessionInfo = await Session . get ( sessionID )
628632 const beforeIdleOutput = { resumePrompt : undefined as string | undefined }
629- await Plugin . trigger ( "session.before.idle" , { sessionID, parentSessionID : sessionInfo ?. parentID } , beforeIdleOutput )
633+ await Plugin . trigger (
634+ "session.before.idle" ,
635+ { sessionID, parentSessionID : sessionInfo ?. parentID , agent : sessionAgent , model : sessionModel } ,
636+ beforeIdleOutput ,
637+ )
630638
631639 if ( beforeIdleOutput . resumePrompt ) {
632640 log . info ( "resuming session" , { sessionID } )
633641 delete state ( ) [ sessionID ]
634642 await prompt ( {
635643 sessionID,
644+ agent : sessionAgent ,
645+ model : sessionModel ,
636646 parts : [ { type : "text" , text : beforeIdleOutput . resumePrompt } ] ,
637647 } )
638648 }
0 commit comments