diff --git a/codex-rs/core/tests/common/test_codex.rs b/codex-rs/core/tests/common/test_codex.rs index fed06241f0..f23e64050f 100644 --- a/codex-rs/core/tests/common/test_codex.rs +++ b/codex-rs/core/tests/common/test_codex.rs @@ -693,25 +693,6 @@ impl TestCodex { .await } - pub async fn submit_turn_with_environments_no_wait( - &self, - prompt: &str, - environments: Option>, - ) -> Result<()> { - self.codex - .submit(Op::UserInput { - environments, - items: vec![UserInput::Text { - text: prompt.into(), - text_elements: Vec::new(), - }], - final_output_json_schema: None, - responsesapi_client_metadata: None, - }) - .await?; - Ok(()) - } - async fn submit_turn_with_permission_profile_context( &self, prompt: &str, diff --git a/codex-rs/core/tests/suite/remote_env.rs b/codex-rs/core/tests/suite/remote_env.rs index 278e4906a1..35d50af278 100644 --- a/codex-rs/core/tests/suite/remote_env.rs +++ b/codex-rs/core/tests/suite/remote_env.rs @@ -13,7 +13,6 @@ use codex_protocol::permissions::FileSystemPath; use codex_protocol::permissions::FileSystemSandboxEntry; use codex_protocol::permissions::FileSystemSandboxPolicy; use codex_protocol::permissions::NetworkSandboxPolicy; -use codex_protocol::protocol::EventMsg; use codex_protocol::protocol::TurnEnvironmentSelection; use codex_utils_absolute_path::AbsolutePathBuf; use core_test_support::PathBufExt; @@ -39,42 +38,6 @@ use std::process::Command; use std::time::SystemTime; use std::time::UNIX_EPOCH; use tempfile::TempDir; -use tokio::time::Duration; - -async fn wait_for_function_call_output( - test: &TestCodex, - response_mock: &core_test_support::responses::ResponseMock, - call_id: &str, -) -> Result { - let mut events = Vec::new(); - let output = tokio::time::timeout(Duration::from_secs(120), async { - loop { - if let Some(output) = response_mock.function_call_output_text(call_id) { - return Ok(output); - } - tokio::select! { - event = test.codex.next_event() => { - let event = event.context("codex event stream ended while waiting for function_call_output")?; - match &event.msg { - EventMsg::Error(error) => { - anyhow::bail!("turn errored before function_call_output for {call_id}: {}", error.message); - } - EventMsg::TurnComplete(_) => { - anyhow::bail!("turn completed before function_call_output for {call_id}; events: {events:?}"); - } - _ => events.push(format!("{:?}", event.msg)), - } - } - _ = tokio::time::sleep(Duration::from_millis(50)) => {} - } - } - }) - .await - .with_context(|| { - format!("timed out waiting for function_call_output for {call_id}; events: {events:?}") - })??; - Ok(output) -} async fn unified_exec_test(server: &wiremock::MockServer) -> Result { let mut builder = test_codex().with_config(|config| { config.use_experimental_unified_exec_tool = true; @@ -211,11 +174,13 @@ async fn exec_command_routing_output( ) .await; - test.submit_turn_with_environments_no_wait("route exec command", environments) + test.submit_turn_with_environments("route exec command", environments) .await?; - let output = wait_for_function_call_output(test, &response_mock, call_id).await?; assert_eq!(response_mock.requests().len(), 2); + let output = response_mock + .function_call_output_text(call_id) + .with_context(|| format!("missing function_call_output for {call_id}"))?; Ok(output) } diff --git a/codex-rs/core/tests/suite/view_image.rs b/codex-rs/core/tests/suite/view_image.rs index 51d8b8e1c9..b23fc6cbdb 100644 --- a/codex-rs/core/tests/suite/view_image.rs +++ b/codex-rs/core/tests/suite/view_image.rs @@ -63,41 +63,6 @@ use wiremock::matchers::body_string_contains; const VIEW_IMAGE_TURN_COMPLETE_TIMEOUT: Duration = Duration::from_secs(30); -async fn wait_for_function_call_output( - test: &TestCodex, - response_mock: &responses::ResponseMock, - call_id: &str, -) -> anyhow::Result { - let mut events = Vec::new(); - let output = tokio::time::timeout(Duration::from_secs(120), async { - loop { - if let Some(output) = response_mock.function_call_output(call_id) { - return Ok(output); - } - tokio::select! { - event = test.codex.next_event() => { - let event = event.context("codex event stream ended while waiting for function_call_output")?; - match &event.msg { - EventMsg::Error(error) => { - anyhow::bail!("turn errored before function_call_output for {call_id}: {}", error.message); - } - EventMsg::TurnComplete(_) => { - anyhow::bail!("turn completed before function_call_output for {call_id}; events: {events:?}"); - } - _ => events.push(format!("{:?}", event.msg)), - } - } - _ = tokio::time::sleep(Duration::from_millis(50)) => {} - } - } - }) - .await - .with_context(|| { - format!("timed out waiting for function_call_output for {call_id}; events: {events:?}") - })??; - Ok(output) -} - fn disabled_user_turn(test: &TestCodex, items: Vec, model: String) -> Op { let (sandbox_policy, permission_profile) = turn_permission_fields(PermissionProfile::Disabled, test.config.cwd.as_path()); @@ -571,14 +536,18 @@ async fn view_image_routes_to_selected_remote_environment() -> anyhow::Result<() ) .await; - test.submit_turn_with_environments_no_wait( + test.submit_turn_with_environments( "route view image", Some(vec![remote_selection, local_selection]), ) .await?; - let output = wait_for_function_call_output(&test, &response_mock, call_id).await?; assert_eq!(response_mock.requests().len(), 2); + let output = response_mock + .last_request() + .context("missing request containing view_image output")? + .function_call_output(call_id) + .clone(); let output_items = output .get("output") .and_then(Value::as_array)