@@ -16,7 +16,7 @@ func TestCacheCompletedResponseCachesCodexNativeToolCalls(t *testing.T) {
1616 resetResponseCacheForTest ()
1717
1818 expandedInput := []byte (`[{"type":"message","role":"user","content":"find a tool"}]` )
19- completed := []byte (`{"type":"response.completed","response":{"id":"resp_native","output":[{"type":"tool_search_call","call_id":"call_search","status":"completed"}]}}` )
19+ completed := []byte (`{"type":"response.completed","response":{"id":"resp_native","output":[{"type":"tool_search_call","id":"ts_123"," call_id":"call_search","status":"completed"}]}}` )
2020
2121 cacheCompletedResponse (expandedInput , completed )
2222
@@ -27,6 +27,9 @@ func TestCacheCompletedResponseCachesCodexNativeToolCalls(t *testing.T) {
2727 if got := gjson .GetBytes (cached [1 ], "call_id" ).String (); got != "call_search" {
2828 t .Fatalf ("cached call_id = %q, want call_search" , got )
2929 }
30+ if got := gjson .GetBytes (cached [1 ], "id" ); got .Exists () {
31+ t .Fatalf ("cached output item id should be stripped for store=false replay, got %s" , got .Raw )
32+ }
3033}
3134
3235func TestExpandPreviousResponseUsesCachedCodexNativeToolContext (t * testing.T ) {
@@ -129,3 +132,33 @@ func TestCacheCompletedResponseDoesNotCacheNonCallIDToolCalls(t *testing.T) {
129132 })
130133 }
131134}
135+
136+ func TestCacheCompletedResponseSkipsReasoningAndMessageOutputItems (t * testing.T ) {
137+ resetResponseCacheForTest ()
138+
139+ cacheCompletedResponse (
140+ []byte (`[{"type":"message","id":"msg_input","role":"user","content":"call a tool"}]` ),
141+ []byte (`{"type":"response.completed","response":{"id":"resp_reasoning","output":[` +
142+ `{"type":"reasoning","id":"rs_0609","encrypted_content":"opaque"},` +
143+ `{"type":"message","id":"msg_output","role":"assistant","content":[{"type":"output_text","text":"thinking"}]},` +
144+ `{"type":"function_call","id":"fc_123","call_id":"call_abc","name":"lookup","arguments":"{}"}` +
145+ `]}}` ),
146+ )
147+
148+ cached := getResponseCache ("resp_reasoning" )
149+ if len (cached ) != 2 {
150+ t .Fatalf ("cached items = %d, want input message + function_call only" , len (cached ))
151+ }
152+ if typ := gjson .GetBytes (cached [0 ], "type" ).String (); typ != "message" {
153+ t .Fatalf ("cached[0].type = %q, want message" , typ )
154+ }
155+ if id := gjson .GetBytes (cached [0 ], "id" ); id .Exists () {
156+ t .Fatalf ("cached input id should be stripped, got %s" , id .Raw )
157+ }
158+ if typ := gjson .GetBytes (cached [1 ], "type" ).String (); typ != "function_call" {
159+ t .Fatalf ("cached[1].type = %q, want function_call" , typ )
160+ }
161+ if id := gjson .GetBytes (cached [1 ], "id" ); id .Exists () {
162+ t .Fatalf ("cached function_call id should be stripped, got %s" , id .Raw )
163+ }
164+ }
0 commit comments