@@ -102,6 +102,29 @@ describe("ContextProxy", () => {
102102 const result = proxy . getGlobalState ( "apiProvider" , "default-value" )
103103 expect ( result ) . toBe ( "default-value" )
104104 } )
105+
106+ it ( "should bypass cache for pass-through state keys" , async ( ) => {
107+ // Setup mock return value
108+ mockGlobalState . get . mockReturnValue ( "pass-through-value" )
109+
110+ // Use a pass-through key (taskHistory)
111+ const result = proxy . getGlobalState ( "taskHistory" as GlobalStateKey )
112+
113+ // Should get value directly from original context
114+ expect ( result ) . toBe ( "pass-through-value" )
115+ expect ( mockGlobalState . get ) . toHaveBeenCalledWith ( "taskHistory" )
116+ } )
117+
118+ it ( "should respect default values for pass-through state keys" , async ( ) => {
119+ // Setup mock to return undefined
120+ mockGlobalState . get . mockReturnValue ( undefined )
121+
122+ // Use a pass-through key with default value
123+ const result = proxy . getGlobalState ( "taskHistory" as GlobalStateKey , "default-value" )
124+
125+ // Should return default value when original context returns undefined
126+ expect ( result ) . toBe ( "default-value" )
127+ } )
105128 } )
106129
107130 describe ( "updateGlobalState" , ( ) => {
@@ -115,6 +138,21 @@ describe("ContextProxy", () => {
115138 const storedValue = await proxy . getGlobalState ( "apiProvider" )
116139 expect ( storedValue ) . toBe ( "new-value" )
117140 } )
141+
142+ it ( "should bypass cache for pass-through state keys" , async ( ) => {
143+ await proxy . updateGlobalState ( "taskHistory" as GlobalStateKey , "new-value" )
144+
145+ // Should update original context
146+ expect ( mockGlobalState . update ) . toHaveBeenCalledWith ( "taskHistory" , "new-value" )
147+
148+ // Setup mock for subsequent get
149+ mockGlobalState . get . mockReturnValue ( "new-value" )
150+
151+ // Should get fresh value from original context
152+ const storedValue = proxy . getGlobalState ( "taskHistory" as GlobalStateKey )
153+ expect ( storedValue ) . toBe ( "new-value" )
154+ expect ( mockGlobalState . get ) . toHaveBeenCalledWith ( "taskHistory" )
155+ } )
118156 } )
119157
120158 describe ( "getSecret" , ( ) => {
0 commit comments