mirror of
https://github.com/openai/codex.git
synced 2026-11-24 23:20:47 +00:00
Add opt-in deferred image generation in code mode (#63594)
## What changed Add `features.defer_image_generation` so code mode can discover the image generation tool through `ALL_TOOLS` without including its definition in the initial model request. Direct exposure remains the default and applies when `image_gen` is excluded from code mode. ## Testing Update the app-server GIF edit test to discover and invoke the deferred tool through code mode. Verify that the initial request omits the tool definition, the discovered definition includes the GIF option, and the edit preserves animation and API defaults. GitOrigin-RevId: 899f689bae0b86099a0ca3736d1cd2576bc3a7a9
This commit is contained in:
@@ -1130,7 +1130,7 @@ generatedImage(result);
|
||||
|
||||
#[cfg(not(windows))]
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn gif_edit_from_code_mode_preserves_animation_and_api_defaults() -> Result<()> {
|
||||
async fn deferred_gif_edit_from_code_mode_preserves_animation_and_api_defaults() -> Result<()> {
|
||||
let call_id = "code-mode-gif-edit";
|
||||
let server = responses::start_mock_server().await;
|
||||
Mock::given(method("POST"))
|
||||
@@ -1152,13 +1152,15 @@ async fn gif_edit_from_code_mode_preserves_animation_and_api_defaults() -> Resul
|
||||
call_id,
|
||||
"exec",
|
||||
r#"
|
||||
const result = await tools.image_gen__imagegen({
|
||||
const imagegen = ALL_TOOLS.find(tool => tool.name === "image_gen__imagegen");
|
||||
const result = await tools[imagegen.name]({
|
||||
prompt: "animate the attached image",
|
||||
gif: {},
|
||||
num_last_images_to_include: 1,
|
||||
});
|
||||
text(result.image_url);
|
||||
generatedImage(result);
|
||||
text(imagegen.description);
|
||||
"#,
|
||||
),
|
||||
responses::ev_completed("resp-1"),
|
||||
@@ -1190,11 +1192,12 @@ generatedImage(result);
|
||||
start_turn(
|
||||
&mut mcp,
|
||||
ThreadStartParams {
|
||||
model: Some("gpt-5.5".into()),
|
||||
config: Some(
|
||||
[(
|
||||
"features.image_generation_animation".to_string(),
|
||||
json!(true),
|
||||
)]
|
||||
[
|
||||
("features.image_generation_animation".into(), json!(true)),
|
||||
("features.defer_image_generation".into(), json!(true)),
|
||||
]
|
||||
.into(),
|
||||
),
|
||||
..Default::default()
|
||||
@@ -1274,7 +1277,8 @@ generatedImage(result);
|
||||
|
||||
let requests = response_mock.requests();
|
||||
assert_eq!(requests.len(), 2);
|
||||
assert!(requests[0].body_contains_text("gif?:"));
|
||||
assert!(!requests[0].body_contains_text("image_gen__imagegen(args:"));
|
||||
assert!(requests[1].body_contains_text("gif?:"));
|
||||
let output = requests[1].custom_tool_call_output(call_id);
|
||||
assert_eq!(
|
||||
output["output"][1],
|
||||
@@ -1295,7 +1299,7 @@ generatedImage(result);
|
||||
.as_str()
|
||||
.is_some_and(|hint| hint.contains(&saved_path.display().to_string()))
|
||||
);
|
||||
assert_eq!(output["output"].as_array().map(Vec::len), Some(4));
|
||||
assert_eq!(output["output"].as_array().map(Vec::len), Some(5));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user