@@ -195,6 +195,23 @@ func TestInstallHooks_AppliesContextInjection(t *testing.T) {
195195 if ! strings .Contains (content , `output.system.push(pendingInjection)` ) {
196196 t .Fatal ("plugin file should push the injection onto the system prompt" )
197197 }
198+ // Every session-reset site must clear the stashed injection so a session
199+ // change cannot leak the prior session's context into the next session.
200+ resetSites := []struct { name , start , end string }{
201+ {"resetSessionTracking" , "function resetSessionTracking" , "return true" },
202+ {"session.deleted" , `case "session.deleted"` , `callHookSync("session-end"` },
203+ {"server.instance.disposed" , `case "server.instance.disposed"` , `callHookSync("session-end"` },
204+ }
205+ for _ , site := range resetSites {
206+ _ , after , found := strings .Cut (content , site .start )
207+ if ! found {
208+ t .Fatalf ("plugin file missing reset site %q" , site .name )
209+ }
210+ body , _ , _ := strings .Cut (after , site .end )
211+ if ! strings .Contains (body , `pendingInjection = null` ) {
212+ t .Fatalf ("%s should clear pendingInjection to avoid cross-session leakage" , site .name )
213+ }
214+ }
198215}
199216
200217func TestInstallHooks_MessageUpdatedFallsBackToSessionStart (t * testing.T ) {
0 commit comments