@@ -111,17 +111,13 @@ async function consumeResponse(response: ReturnType<typeof createOpenAIResponses
111111 return events ;
112112}
113113
114- function createStream (
115- request : Record < string , unknown > ,
116- overrides : { continuationItems ?: Array < Record < string , unknown > > ; sessionId ?: string } = { } ,
117- ) {
114+ function createStream ( request : Record < string , unknown > , overrides : { sessionId ?: string } = { } ) {
118115 return createOpenAIResponsesWebSocketStream ( {
119116 client,
120117 request,
121118 mode : "websocket-cached" ,
122119 sessionId : overrides . sessionId ?? "session-1" ,
123120 headers : { "x-stable-session" : "session-1" } ,
124- resolveContinuationItems : ( ) => ( overrides . continuationItems ?? [ assistantOutput ] ) as never ,
125121 } ) ;
126122}
127123
@@ -210,79 +206,13 @@ describe("native OpenAI Responses WebSocket transport", () => {
210206 } ) ;
211207 } ) ;
212208
213- it ( "reuses a session socket and sends only a strict append-compatible input delta" , async ( ) => {
214- websocketState . responseBatches . push (
215- [ completion ( "resp_1" , [ assistantOutput ] ) ] ,
216- [ completion ( "resp_2" ) ] ,
217- ) ;
218- const stableRequest = {
219- model : "gpt-5.6-luna" ,
220- stream : true ,
221- background : true ,
222- store : false ,
223- instructions : "stable prompt" ,
224- tools : [ { type : "function" , name : "read" , parameters : { type : "object" } } ] ,
225- metadata : {
226- openclaw_session_id : "session-1" ,
227- openclaw_turn_id : "turn-1" ,
228- openclaw_turn_attempt : "1" ,
229- } ,
230- input : [ firstUser ] ,
231- } ;
232-
233- const first = createStream ( stableRequest ) ;
234- expect ( first . continuationStatus ) . toBe ( "no_previous_response" ) ;
235- expect ( first . request ) . not . toHaveProperty ( "stream" ) ;
236- expect ( first . request ) . not . toHaveProperty ( "background" ) ;
237- await consumeResponse ( first ) ;
238-
239- const second = createStream ( {
240- ...stableRequest ,
241- metadata : {
242- openclaw_session_id : "session-1" ,
243- openclaw_turn_id : "turn-2" ,
244- openclaw_turn_attempt : "1" ,
245- } ,
246- input : [
247- firstUser ,
248- {
249- type : "message" ,
250- role : "assistant" ,
251- content : assistantOutput . content ,
252- } ,
253- { role : "user" , content : "second" } ,
254- ] ,
255- } ) ;
256- expect ( second . continuationStatus ) . toBe ( "continued" ) ;
257- expect ( second . request ) . toMatchObject ( {
258- previous_response_id : "resp_1" ,
259- input : [ { role : "user" , content : "second" } ] ,
260- } ) ;
261- await consumeResponse ( second ) ;
262-
263- expect ( websocketState . instances ) . toHaveLength ( 1 ) ;
264- expect ( websocketState . requests ) . toHaveLength ( 2 ) ;
265- expect ( websocketState . requests [ 1 ] ) . toMatchObject ( {
266- type : "response.create" ,
267- previous_response_id : "resp_1" ,
268- input : [ { role : "user" , content : "second" } ] ,
269- } ) ;
270- expect ( websocketState . requests [ 0 ] ) . not . toHaveProperty ( "stream" ) ;
271- expect ( websocketState . requests [ 0 ] ) . not . toHaveProperty ( "background" ) ;
272- } ) ;
273-
274209 it ( "uses the response id when persisted encrypted reasoning has a different replay shape" , async ( ) => {
275210 const reasoning = { type : "reasoning" , id : "rs_1" , encrypted_content : "ciphertext" } ;
276211 websocketState . responseBatches . push (
277212 [ completion ( "resp_1" , [ reasoning , assistantOutput ] ) ] ,
278213 [ completion ( "resp_2" ) ] ,
279214 ) ;
280- await consumeResponse (
281- createStream (
282- { model : "gpt-5.6-luna" , input : [ firstUser ] } ,
283- { continuationItems : [ reasoning , assistantOutput ] } ,
284- ) ,
285- ) ;
215+ await consumeResponse ( createStream ( { model : "gpt-5.6-luna" , input : [ firstUser ] } ) ) ;
286216
287217 const second = createStream ( {
288218 model : "gpt-5.6-luna" ,
0 commit comments