@@ -144,6 +144,8 @@ const DISABLED_CODEX_WEB_SEARCH_THREAD_CONFIG_FINGERPRINT = JSON.stringify({
144144 "features.standalone_web_search" : false ,
145145 web_search : "disabled" ,
146146} ) ;
147+ const TINY_PNG_BASE64 =
148+ "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+/p9sAAAAASUVORK5CYII=" ;
147149
148150async function writeExistingBinding (
149151 sessionFile : string ,
@@ -3806,14 +3808,12 @@ describe("runCodexAppServerAttempt", () => {
38063808 path . join ( tempDir , "session.jsonl" ) ,
38073809 path . join ( tempDir , "workspace" ) ,
38083810 ) ;
3809- const pngBase64 =
3810- "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+/p9sAAAAASUVORK5CYII=" ;
38113811 params . model = createCodexTestModel ( "codex" , [ "text" , "image" ] ) ;
38123812 params . images = [
38133813 {
38143814 type : "image" ,
38153815 mimeType : "image/png" ,
3816- data : pngBase64 ,
3816+ data : TINY_PNG_BASE64 ,
38173817 } ,
38183818 ] ;
38193819
@@ -3828,7 +3828,7 @@ describe("runCodexAppServerAttempt", () => {
38283828 | undefined ;
38293829 expect ( turnStartParams ?. input ) . toEqual ( [
38303830 { type : "text" , text : "hello" , text_elements : [ ] } ,
3831- { type : "image" , url : `data:image/png;base64,${ pngBase64 } ` } ,
3831+ { type : "image" , url : `data:image/png;base64,${ TINY_PNG_BASE64 } ` } ,
38323832 ] ) ;
38333833 } ) ;
38343834
@@ -3965,12 +3965,14 @@ describe("runCodexAppServerAttempt", () => {
39653965 expect ( result . timedOut ) . toBe ( false ) ;
39663966 } ) ;
39673967
3968- it ( "surfaces Codex-native image generation saved paths as reply media" , async ( ) => {
3968+ it ( "persists Codex-native image results as gateway-managed reply media" , async ( ) => {
39693969 const harness = createStartedThreadHarness ( ) ;
39703970 const params = createParams (
39713971 path . join ( tempDir , "session.jsonl" ) ,
39723972 path . join ( tempDir , "workspace" ) ,
39733973 ) ;
3974+ const savedPath = "/tmp/codex-home/generated_images/session-1/ig_123.png" ;
3975+ vi . stubEnv ( "OPENCLAW_STATE_DIR" , path . join ( tempDir , "state" ) ) ;
39743976
39753977 const run = runCodexAppServerAttempt ( params ) ;
39763978 await harness . waitForMethod ( "turn/start" ) ;
@@ -3988,17 +3990,24 @@ describe("runCodexAppServerAttempt", () => {
39883990 id : "ig_123" ,
39893991 status : "completed" ,
39903992 revisedPrompt : "A tiny blue square" ,
3991- result : "Zm9v" ,
3992- savedPath : "/tmp/codex-home/generated_images/session-1/ig_123.png" ,
3993+ result : TINY_PNG_BASE64 ,
3994+ savedPath,
39933995 } ,
39943996 ] ,
39953997 } ,
39963998 } ,
39973999 } ) ;
39984000
39994001 const result = await run ;
4002+ const mediaUrl = result . toolMediaUrls ?. [ 0 ] ;
4003+
40004004 expect ( result . assistantTexts ) . toEqual ( [ ] ) ;
4001- expect ( result . toolMediaUrls ) . toEqual ( [ "/tmp/codex-home/generated_images/session-1/ig_123.png" ] ) ;
4005+ expect ( result . toolMediaUrls ) . toHaveLength ( 1 ) ;
4006+ expect ( mediaUrl ) . not . toBe ( savedPath ) ;
4007+ expect ( mediaUrl ) . toContain ( `${ path . sep } media${ path . sep } tool-image-generation${ path . sep } ` ) ;
4008+ await expect ( fs . readFile ( mediaUrl ?? "" ) ) . resolves . toEqual (
4009+ Buffer . from ( TINY_PNG_BASE64 , "base64" ) ,
4010+ ) ;
40024011 } ) ;
40034012
40044013 it ( "does not complete on unscoped turn/completed notifications" , async ( ) => {
0 commit comments