@@ -2824,6 +2824,42 @@ describe("SessionRunnerLLM", () => {
28242824 } ) ,
28252825 )
28262826
2827+ it . effect ( "bounds external session prompt cache keys" , ( ) =>
2828+ Effect . gen ( function * ( ) {
2829+ yield * setup
2830+ const externalSessionID = SessionV2 . ID . fromExternal ( {
2831+ namespace : "discord" ,
2832+ key : "thread-one" ,
2833+ } )
2834+ const otherExternalSessionID = SessionV2 . ID . fromExternal ( {
2835+ namespace : "discord" ,
2836+ key : "thread-two" ,
2837+ } )
2838+ yield * insertSession ( externalSessionID )
2839+ yield * insertSession ( otherExternalSessionID )
2840+ const session = yield * SessionV2 . Service
2841+ yield * session . prompt ( {
2842+ sessionID : externalSessionID ,
2843+ prompt : new Prompt ( { text : "Run external session" } ) ,
2844+ resume : false ,
2845+ } )
2846+ yield * session . prompt ( {
2847+ sessionID : otherExternalSessionID ,
2848+ prompt : new Prompt ( { text : "Run other external session" } ) ,
2849+ resume : false ,
2850+ } )
2851+
2852+ requests . length = 0
2853+ yield * session . resume ( externalSessionID )
2854+ yield * session . resume ( otherExternalSessionID )
2855+
2856+ const keys = requests . map ( ( request ) => request . providerOptions ?. openai ?. promptCacheKey )
2857+ expect ( keys ) . toEqual ( [ externalSessionID . slice ( 4 ) , otherExternalSessionID . slice ( 4 ) ] )
2858+ expect ( keys . every ( ( key ) => typeof key === "string" && key . length === 64 ) ) . toBe ( true )
2859+ expect ( keys [ 0 ] ) . not . toBe ( keys [ 1 ] )
2860+ } ) ,
2861+ )
2862+
28272863 it . effect ( "fans out one failed run and allows a later retry" , ( ) =>
28282864 Effect . gen ( function * ( ) {
28292865 yield * setup
0 commit comments