@@ -183,6 +183,58 @@ describe("Responses API adapter", () => {
183183 assert . equal ( body . max_output_tokens , 4096 ) ;
184184 } ) ;
185185
186+ it ( "accepts the live Codex singleton content payload" , ( ) => {
187+ const request = {
188+ model : "coding-route" ,
189+ input : [
190+ { type : "message" , role : "user" , content : { type : "input_text" , text : "hello" } } ,
191+ ] ,
192+ } ;
193+ const body = toChatCompletionsBody ( request ) ;
194+ assert . deepEqual ( request . input [ 0 ] . content , [ { type : "input_text" , text : "hello" } ] ) ;
195+ assert . deepEqual ( body . messages , [ { role : "user" , content : [ { type : "text" , text : "hello" } ] } ] ) ;
196+ } ) ;
197+
198+ it ( "accepts supported singleton parts, empty assistant content, and nullable reasoning" , ( ) => {
199+ const body = toChatCompletionsBody ( {
200+ model : "route" ,
201+ input : [
202+ { type : "message" , role : "user" , content : { type : "input_image" , image_url : "data:image/png;base64,QUJD" } } ,
203+ { type : "message" , role : "assistant" , content : null } ,
204+ { type : "message" , role : "assistant" } ,
205+ { type : "reasoning" , id : "rs_unavailable" , encrypted_content : null , summary : [ ] } ,
206+ { type : "function_call" , call_id : "call_1" , name : "shell" , arguments : "{}" } ,
207+ ] ,
208+ } ) ;
209+ assert . equal ( body . messages [ 0 ] . content [ 0 ] . type , "image_url" ) ;
210+ assert . deepEqual ( body . messages . slice ( 1 , 3 ) , [
211+ { role : "assistant" , content : null } ,
212+ { role : "assistant" , content : undefined } ,
213+ ] ) ;
214+ assert . equal ( body . messages [ 3 ] . tool_calls [ 0 ] . extra_content , undefined ) ;
215+ } ) ;
216+
217+ it ( "rejects arbitrary singleton objects and invalid adjacent shapes" , ( ) => {
218+ for ( const [ content , param ] of [
219+ [ { foo : "bar" } , "input[0].content" ] ,
220+ [ { type : "input_text" , text : 1 } , "input[0].content.text" ] ,
221+ [ { type : "unknown" , text : "x" } , "input[0].content.type" ] ,
222+ ] ) {
223+ assert . throws (
224+ ( ) => toChatCompletionsBody ( { model : "route" , input : [ { type : "message" , role : "user" , content } ] } ) ,
225+ ( error ) => error . status === 400 && error . error . param === param
226+ ) ;
227+ }
228+ assert . throws (
229+ ( ) => toChatCompletionsBody ( { model : "route" , input : [ { type : "message" , role : "user" , content : null } ] } ) ,
230+ ( error ) => error . status === 400 && error . error . param === "input[0].content"
231+ ) ;
232+ assert . throws (
233+ ( ) => toChatCompletionsBody ( { model : "route" , input : [ { type : "reasoning" , encrypted_content : { } } ] } ) ,
234+ ( error ) => error . status === 400 && error . error . param === "input[0].encrypted_content"
235+ ) ;
236+ } ) ;
237+
186238 it ( "rejects malformed input and stateless continuation IDs" , ( ) => {
187239 assert . throws (
188240 ( ) => toChatCompletionsBody ( { model : "route" , input : [ { type : "function_call" , name : "x" , arguments : "{}" } ] } ) ,
@@ -192,6 +244,10 @@ describe("Responses API adapter", () => {
192244 ( ) => toChatCompletionsBody ( { model : "route" , input : "hi" , previous_response_id : "resp_prior" } ) ,
193245 ( error ) => error . status === 400 && error . error . param === "previous_response_id"
194246 ) ;
247+ assert . throws (
248+ ( ) => toChatCompletionsBody ( { model : "route" , input : [ { type : "item_reference" , id : "rs_prior" } ] } ) ,
249+ ( error ) => error . status === 400 && error . error . param === "input[0]" && / s t a t e l e s s / . test ( error . message )
250+ ) ;
195251 } ) ;
196252
197253 it ( "preserves the requested route and marks length-limited responses incomplete" , ( ) => {
0 commit comments