From ba95d9862c0f59fa296da56dcfd5fd870ac70005 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Tue, 28 Oct 2025 16:42:46 -0500 Subject: [PATCH] Fixed bug that results in a sporadic hang when attaching images (#5891) Addresses https://github.com/openai/codex/issues/5773 Testing: I tested that images work (regardless of order that they are associated with the task prompt) in both the CLI and Extension. Also verified that conversations in CLI and extension with images can be resumed. --- codex-rs/exec/src/lib.rs | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/codex-rs/exec/src/lib.rs b/codex-rs/exec/src/lib.rs index 559fd980..af45a7d2 100644 --- a/codex-rs/exec/src/lib.rs +++ b/codex-rs/exec/src/lib.rs @@ -24,7 +24,6 @@ use codex_core::protocol::Event; use codex_core::protocol::EventMsg; use codex_core::protocol::Op; use codex_core::protocol::SessionSource; -use codex_core::protocol::TaskCompleteEvent; use codex_ollama::DEFAULT_OSS_MODEL; use codex_protocol::config_types::SandboxMode; use codex_protocol::user_input::UserInput; @@ -323,30 +322,12 @@ pub async fn run_main(cli: Cli, codex_linux_sandbox_exe: Option) -> any }); } - // Send images first, if any. - if !images.is_empty() { - let items: Vec = images - .into_iter() - .map(|path| UserInput::LocalImage { path }) - .collect(); - let initial_images_event_id = conversation.submit(Op::UserInput { items }).await?; - info!("Sent images with event ID: {initial_images_event_id}"); - while let Ok(event) = conversation.next_event().await { - if event.id == initial_images_event_id - && matches!( - event.msg, - EventMsg::TaskComplete(TaskCompleteEvent { - last_agent_message: _, - }) - ) - { - break; - } - } - } - - // Send the prompt. - let items: Vec = vec![UserInput::Text { text: prompt }]; + // Package images and prompt into a single user input turn. + let mut items: Vec = images + .into_iter() + .map(|path| UserInput::LocalImage { path }) + .collect(); + items.push(UserInput::Text { text: prompt }); let initial_prompt_task_id = conversation .submit(Op::UserTurn { items,