@@ -4176,20 +4176,46 @@ describe("qa mock openai server", () => {
41764176
41774177 it ( "completes an image without replaying a tool unavailable to the completion turn" , async ( ) => {
41784178 const server = await startMockServer ( ) ;
4179+ const prompt = "Image generation check: generate a QA lighthouse image." ;
4180+ const imagePlan = await expectResponsesJson < unknown > ( server , {
4181+ stream : false ,
4182+ tools : [ IMAGE_GENERATE_TOOL ] ,
4183+ input : [ makeUserInput ( prompt ) ] ,
4184+ } ) ;
4185+ const imageCall = outputToolCall ( imagePlan , "image_generate" ) ;
4186+ const callId = outputToolCallId ( imageCall , "call_mock_image_generate_unavailable" ) ;
4187+ const completionEvent = [
4188+ "<<<BEGIN_OPENCLAW_INTERNAL_CONTEXT>>>" ,
4189+ "OpenClaw runtime context (internal):" ,
4190+ "" ,
4191+ "[Internal task completion event]" ,
4192+ "source: image_generation" ,
4193+ "task: A QA lighthouse on a dark sea with a tiny protocol droid silhouette." ,
4194+ "status: completed successfully" ,
4195+ "Generated media:" ,
4196+ "MEDIA:/tmp/qa-lighthouse.png" ,
4197+ "<<<END_OPENCLAW_INTERNAL_CONTEXT>>>" ,
4198+ ] . join ( "\n" ) ;
41794199 const completion = await expectResponsesJson < unknown > ( server , {
41804200 stream : false ,
41814201 tools : [ MESSAGE_TOOL ] ,
41824202 input : [
4183- makeUserInput ( "Image generation check: generate a QA lighthouse image." ) ,
4184- makeUserInput (
4185- [
4186- "[Internal task completion event]" ,
4187- "source: image_generation" ,
4188- "status: completed successfully" ,
4189- "Generated media:" ,
4190- "MEDIA:/tmp/qa-lighthouse.png" ,
4191- ] . join ( "\n" ) ,
4192- ) ,
4203+ makeUserInput ( prompt ) ,
4204+ {
4205+ type : "function_call" ,
4206+ name : "image_generate" ,
4207+ call_id : callId ,
4208+ arguments : String ( imageCall . arguments ) ,
4209+ } ,
4210+ {
4211+ type : "function_call_output" ,
4212+ call_id : callId ,
4213+ output : JSON . stringify ( {
4214+ content : [ { type : "text" , text : "Background image generation started." } ] ,
4215+ details : { async : true , status : "started" } ,
4216+ } ) ,
4217+ } ,
4218+ makeUserInput ( completionEvent ) ,
41934219 ] ,
41944220 } ) ;
41954221
0 commit comments