@@ -249,6 +249,50 @@ func TestApplyCodexOAuthTransform_NonCodexCLI_PreservesExistingInstructions(t *t
249249 require .Equal (t , "old instructions" , instructions )
250250}
251251
252+ func TestApplyCodexOAuthTransform_StringInputConvertedToArray (t * testing.T ) {
253+ reqBody := map [string ]any {"model" : "gpt-5.4" , "input" : "Hello, world!" }
254+ result := applyCodexOAuthTransform (reqBody , false , false )
255+ require .True (t , result .Modified )
256+ input , ok := reqBody ["input" ].([]any )
257+ require .True (t , ok )
258+ require .Len (t , input , 1 )
259+ msg , ok := input [0 ].(map [string ]any )
260+ require .True (t , ok )
261+ require .Equal (t , "message" , msg ["type" ])
262+ require .Equal (t , "user" , msg ["role" ])
263+ require .Equal (t , "Hello, world!" , msg ["content" ])
264+ }
265+
266+ func TestApplyCodexOAuthTransform_EmptyStringInputBecomesEmptyArray (t * testing.T ) {
267+ reqBody := map [string ]any {"model" : "gpt-5.4" , "input" : "" }
268+ result := applyCodexOAuthTransform (reqBody , false , false )
269+ require .True (t , result .Modified )
270+ input , ok := reqBody ["input" ].([]any )
271+ require .True (t , ok )
272+ require .Len (t , input , 0 )
273+ }
274+
275+ func TestApplyCodexOAuthTransform_WhitespaceStringInputBecomesEmptyArray (t * testing.T ) {
276+ reqBody := map [string ]any {"model" : "gpt-5.4" , "input" : " " }
277+ result := applyCodexOAuthTransform (reqBody , false , false )
278+ require .True (t , result .Modified )
279+ input , ok := reqBody ["input" ].([]any )
280+ require .True (t , ok )
281+ require .Len (t , input , 0 )
282+ }
283+
284+ func TestApplyCodexOAuthTransform_StringInputWithToolsField (t * testing.T ) {
285+ reqBody := map [string ]any {
286+ "model" : "gpt-5.4" ,
287+ "input" : "Run the tests" ,
288+ "tools" : []any {map [string ]any {"type" : "function" , "name" : "bash" }},
289+ }
290+ applyCodexOAuthTransform (reqBody , false , false )
291+ input , ok := reqBody ["input" ].([]any )
292+ require .True (t , ok )
293+ require .Len (t , input , 1 )
294+ }
295+
252296func TestIsInstructionsEmpty (t * testing.T ) {
253297 tests := []struct {
254298 name string
0 commit comments