From 6057884765a1b64e9963881c83aec440554f48aa Mon Sep 17 00:00:00 2001 From: pakrym-oai Date: Fri, 20 Mar 2026 09:02:54 -0700 Subject: [PATCH] Make view_image integration tests remote-aware --- codex-rs/core/tests/suite/code_mode.rs | 18 +- codex-rs/core/tests/suite/view_image.rs | 303 ++++++++++++++---------- 2 files changed, 190 insertions(+), 131 deletions(-) diff --git a/codex-rs/core/tests/suite/code_mode.rs b/codex-rs/core/tests/suite/code_mode.rs index c74de38e86..0c251034af 100644 --- a/codex-rs/core/tests/suite/code_mode.rs +++ b/codex-rs/core/tests/suite/code_mode.rs @@ -5,6 +5,7 @@ use base64::Engine; use base64::engine::general_purpose::STANDARD as BASE64_STANDARD; use codex_core::config::types::McpServerConfig; use codex_core::config::types::McpServerTransportConfig; +use codex_exec_server::CreateDirectoryOptions; use codex_features::Feature; use codex_protocol::dynamic_tools::DynamicToolCallOutputContentItem; use codex_protocol::dynamic_tools::DynamicToolResponse; @@ -14,6 +15,7 @@ use codex_protocol::protocol::EventMsg; use codex_protocol::protocol::Op; use codex_protocol::protocol::SandboxPolicy; use codex_protocol::user_input::UserInput; +use codex_utils_absolute_path::AbsolutePathBuf; use core_test_support::assert_regex_match; use core_test_support::responses; use core_test_support::responses::ResponseMock; @@ -1806,13 +1808,23 @@ async fn code_mode_can_use_view_image_result_with_image_helper() -> Result<()> { let _ = config.features.enable(Feature::CodeMode); let _ = config.features.enable(Feature::ImageDetailOriginal); }); - let test = builder.build(&server).await?; + let test = builder.build_remote_aware(&server).await?; let image_bytes = BASE64_STANDARD.decode( "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/iZk9HQAAAABJRU5ErkJggg==", )?; - let image_path = test.cwd_path().join("code_mode_view_image.png"); - fs::write(&image_path, image_bytes)?; + let image_path = test.config.cwd.join("code_mode_view_image.png"); + if let Some(parent) = image_path.parent() { + test.fs() + .create_directory( + &AbsolutePathBuf::try_from(parent.to_path_buf())?, + CreateDirectoryOptions { recursive: true }, + ) + .await?; + } + test.fs() + .write_file(&AbsolutePathBuf::try_from(image_path.clone())?, image_bytes) + .await?; let image_path_json = serde_json::to_string(&image_path.to_string_lossy().to_string())?; let code = format!( diff --git a/codex-rs/core/tests/suite/view_image.rs b/codex-rs/core/tests/suite/view_image.rs index f0cc6a9892..51c5cdd0d8 100644 --- a/codex-rs/core/tests/suite/view_image.rs +++ b/codex-rs/core/tests/suite/view_image.rs @@ -83,28 +83,80 @@ fn absolute_path(path: &Path) -> anyhow::Result anyhow::Result> { + let image = ImageBuffer::from_pixel(width, height, Rgba(rgba)); + let mut cursor = Cursor::new(Vec::new()); + DynamicImage::ImageRgba8(image).write_to(&mut cursor, image::ImageFormat::Png)?; + Ok(cursor.into_inner()) +} + +async fn create_workspace_directory(test: &TestCodex, rel_path: &str) -> anyhow::Result { + let abs_path = test.config.cwd.join(rel_path); + test.fs() + .create_directory( + &absolute_path(&abs_path)?, + CreateDirectoryOptions { recursive: true }, + ) + .await?; + Ok(abs_path) +} + +async fn write_workspace_file( + test: &TestCodex, + rel_path: &str, + contents: Vec, +) -> anyhow::Result { + let abs_path = test.config.cwd.join(rel_path); + if let Some(parent) = abs_path.parent() { + test.fs() + .create_directory( + &absolute_path(parent)?, + CreateDirectoryOptions { recursive: true }, + ) + .await?; + } + test.fs() + .write_file(&absolute_path(&abs_path)?, contents) + .await?; + Ok(abs_path) +} + +async fn write_workspace_png( + test: &TestCodex, + rel_path: &str, + width: u32, + height: u32, + rgba: [u8; 4], +) -> anyhow::Result { + write_workspace_file(test, rel_path, png_bytes(width, height, rgba)?).await +} + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn user_turn_with_local_image_attaches_image() -> anyhow::Result<()> { skip_if_no_network!(Ok(())); let server = start_mock_server().await; + let mut builder = test_codex(); + let test = builder.build_remote_aware(&server).await?; let TestCodex { codex, - cwd, + config, session_configured, .. - } = test_codex().build(&server).await?; + } = &test; let rel_path = "user-turn/example.png"; - let abs_path = cwd.path().join(rel_path); - if let Some(parent) = abs_path.parent() { - std::fs::create_dir_all(parent)?; - } let original_width = 2304; let original_height = 864; - let image = ImageBuffer::from_pixel(original_width, original_height, Rgba([20u8, 40, 60, 255])); - image.save(&abs_path)?; + let abs_path = write_workspace_png( + &test, + rel_path, + original_width, + original_height, + [20u8, 40, 60, 255], + ) + .await?; let response = sse(vec![ ev_response_created("resp-1"), @@ -121,7 +173,7 @@ async fn user_turn_with_local_image_attaches_image() -> anyhow::Result<()> { path: abs_path.clone(), }], final_output_json_schema: None, - cwd: cwd.path().to_path_buf(), + cwd: config.cwd.clone(), approval_policy: AskForApproval::Never, sandbox_policy: SandboxPolicy::DangerFullAccess, model: session_model, @@ -134,7 +186,7 @@ async fn user_turn_with_local_image_attaches_image() -> anyhow::Result<()> { .await?; wait_for_event_with_timeout( - &codex, + codex, |event| matches!(event, EventMsg::TurnComplete(_)), // Empirically, image attachment can be slow under Bazel/RBE. Duration::from_secs(10), @@ -191,27 +243,18 @@ async fn view_image_tool_attaches_local_image() -> anyhow::Result<()> { } = &test; let cwd = config.cwd.clone(); - let rel_path = PathBuf::from("assets/example.png"); - let abs_path = cwd.join(&rel_path); - let abs_path_absolute = absolute_path(&abs_path)?; - let assets_dir = cwd.join("assets"); - - let file_system = test.fs(); - + let rel_path = "assets/example.png"; + let abs_path = cwd.join(rel_path); let original_width = 2304; let original_height = 864; - let image = ImageBuffer::from_pixel(original_width, original_height, Rgba([255u8, 0, 0, 255])); - let mut cursor = Cursor::new(Vec::new()); - DynamicImage::ImageRgba8(image).write_to(&mut cursor, image::ImageFormat::Png)?; - file_system - .create_directory( - &absolute_path(&assets_dir)?, - CreateDirectoryOptions { recursive: true }, - ) - .await?; - file_system - .write_file(&abs_path_absolute, cursor.into_inner()) - .await?; + write_workspace_png( + &test, + rel_path, + original_width, + original_height, + [255u8, 0, 0, 255], + ) + .await?; let call_id = "view-image-call"; let arguments = serde_json::json!({ "path": rel_path }).to_string(); @@ -333,22 +376,25 @@ async fn view_image_tool_can_preserve_original_resolution_when_requested_on_gpt5 .enable(Feature::ImageDetailOriginal) .expect("test config should allow feature update"); }); + let test = builder.build_remote_aware(&server).await?; let TestCodex { codex, - cwd, + config, session_configured, .. - } = builder.build(&server).await?; + } = &test; let rel_path = "assets/original-example.png"; - let abs_path = cwd.path().join(rel_path); - if let Some(parent) = abs_path.parent() { - std::fs::create_dir_all(parent)?; - } let original_width = 2304; let original_height = 864; - let image = ImageBuffer::from_pixel(original_width, original_height, Rgba([0u8, 80, 255, 255])); - image.save(&abs_path)?; + write_workspace_png( + &test, + rel_path, + original_width, + original_height, + [0u8, 80, 255, 255], + ) + .await?; let call_id = "view-image-original"; let arguments = serde_json::json!({ "path": rel_path, "detail": "original" }).to_string(); @@ -375,7 +421,7 @@ async fn view_image_tool_can_preserve_original_resolution_when_requested_on_gpt5 text_elements: Vec::new(), }], final_output_json_schema: None, - cwd: cwd.path().to_path_buf(), + cwd: config.cwd.clone(), approval_policy: AskForApproval::Never, sandbox_policy: SandboxPolicy::DangerFullAccess, model: session_model, @@ -388,7 +434,7 @@ async fn view_image_tool_can_preserve_original_resolution_when_requested_on_gpt5 .await?; wait_for_event_with_timeout( - &codex, + codex, |event| matches!(event, EventMsg::TurnComplete(_)), Duration::from_secs(10), ) @@ -437,20 +483,16 @@ async fn view_image_tool_errors_clearly_for_unsupported_detail_values() -> anyho .enable(Feature::ImageDetailOriginal) .expect("test config should allow feature update"); }); + let test = builder.build_remote_aware(&server).await?; let TestCodex { codex, - cwd, + config, session_configured, .. - } = builder.build(&server).await?; + } = &test; let rel_path = "assets/unsupported-detail.png"; - let abs_path = cwd.path().join(rel_path); - if let Some(parent) = abs_path.parent() { - std::fs::create_dir_all(parent)?; - } - let image = ImageBuffer::from_pixel(256, 128, Rgba([0u8, 80, 255, 255])); - image.save(&abs_path)?; + write_workspace_png(&test, rel_path, 256, 128, [0u8, 80, 255, 255]).await?; let call_id = "view-image-unsupported-detail"; let arguments = serde_json::json!({ "path": rel_path, "detail": "low" }).to_string(); @@ -477,7 +519,7 @@ async fn view_image_tool_errors_clearly_for_unsupported_detail_values() -> anyho text_elements: Vec::new(), }], final_output_json_schema: None, - cwd: cwd.path().to_path_buf(), + cwd: config.cwd.clone(), approval_policy: AskForApproval::Never, sandbox_policy: SandboxPolicy::DangerFullAccess, model: session_model, @@ -489,7 +531,7 @@ async fn view_image_tool_errors_clearly_for_unsupported_detail_values() -> anyho }) .await?; - wait_for_event(&codex, |event| matches!(event, EventMsg::TurnComplete(_))).await; + wait_for_event(codex, |event| matches!(event, EventMsg::TurnComplete(_))).await; let req = mock.single_request(); let body_with_tool_output = req.body_json(); @@ -523,22 +565,25 @@ async fn view_image_tool_treats_null_detail_as_omitted() -> anyhow::Result<()> { .enable(Feature::ImageDetailOriginal) .expect("test config should allow feature update"); }); + let test = builder.build_remote_aware(&server).await?; let TestCodex { codex, - cwd, + config, session_configured, .. - } = builder.build(&server).await?; + } = &test; let rel_path = "assets/null-detail.png"; - let abs_path = cwd.path().join(rel_path); - if let Some(parent) = abs_path.parent() { - std::fs::create_dir_all(parent)?; - } let original_width = 2304; let original_height = 864; - let image = ImageBuffer::from_pixel(original_width, original_height, Rgba([0u8, 80, 255, 255])); - image.save(&abs_path)?; + write_workspace_png( + &test, + rel_path, + original_width, + original_height, + [0u8, 80, 255, 255], + ) + .await?; let call_id = "view-image-null-detail"; let arguments = serde_json::json!({ "path": rel_path, "detail": null }).to_string(); @@ -565,7 +610,7 @@ async fn view_image_tool_treats_null_detail_as_omitted() -> anyhow::Result<()> { text_elements: Vec::new(), }], final_output_json_schema: None, - cwd: cwd.path().to_path_buf(), + cwd: config.cwd.clone(), approval_policy: AskForApproval::Never, sandbox_policy: SandboxPolicy::DangerFullAccess, model: session_model, @@ -577,7 +622,7 @@ async fn view_image_tool_treats_null_detail_as_omitted() -> anyhow::Result<()> { }) .await?; - wait_for_event(&codex, |event| matches!(event, EventMsg::TurnComplete(_))).await; + wait_for_event(codex, |event| matches!(event, EventMsg::TurnComplete(_))).await; let req = mock.single_request(); let function_output = req.function_call_output(call_id); @@ -619,22 +664,25 @@ async fn view_image_tool_resizes_when_model_lacks_original_detail_support() -> a .enable(Feature::ImageDetailOriginal) .expect("test config should allow feature update"); }); + let test = builder.build_remote_aware(&server).await?; let TestCodex { codex, - cwd, + config, session_configured, .. - } = builder.build(&server).await?; + } = &test; let rel_path = "assets/original-example-lower-model.png"; - let abs_path = cwd.path().join(rel_path); - if let Some(parent) = abs_path.parent() { - std::fs::create_dir_all(parent)?; - } let original_width = 2304; let original_height = 864; - let image = ImageBuffer::from_pixel(original_width, original_height, Rgba([0u8, 80, 255, 255])); - image.save(&abs_path)?; + write_workspace_png( + &test, + rel_path, + original_width, + original_height, + [0u8, 80, 255, 255], + ) + .await?; let call_id = "view-image-original-lower-model"; let arguments = serde_json::json!({ "path": rel_path }).to_string(); @@ -661,7 +709,7 @@ async fn view_image_tool_resizes_when_model_lacks_original_detail_support() -> a text_elements: Vec::new(), }], final_output_json_schema: None, - cwd: cwd.path().to_path_buf(), + cwd: config.cwd.clone(), approval_policy: AskForApproval::Never, sandbox_policy: SandboxPolicy::DangerFullAccess, model: session_model, @@ -674,7 +722,7 @@ async fn view_image_tool_resizes_when_model_lacks_original_detail_support() -> a .await?; wait_for_event_with_timeout( - &codex, + codex, |event| matches!(event, EventMsg::TurnComplete(_)), Duration::from_secs(10), ) @@ -726,22 +774,25 @@ async fn view_image_tool_does_not_force_original_resolution_with_capability_feat .enable(Feature::ImageDetailOriginal) .expect("test config should allow feature update"); }); + let test = builder.build_remote_aware(&server).await?; let TestCodex { codex, - cwd, + config, session_configured, .. - } = builder.build(&server).await?; + } = &test; let rel_path = "assets/original-example-capability-only.png"; - let abs_path = cwd.path().join(rel_path); - if let Some(parent) = abs_path.parent() { - std::fs::create_dir_all(parent)?; - } let original_width = 2304; let original_height = 864; - let image = ImageBuffer::from_pixel(original_width, original_height, Rgba([0u8, 80, 255, 255])); - image.save(&abs_path)?; + write_workspace_png( + &test, + rel_path, + original_width, + original_height, + [0u8, 80, 255, 255], + ) + .await?; let call_id = "view-image-capability-only"; let arguments = serde_json::json!({ "path": rel_path }).to_string(); @@ -768,7 +819,7 @@ async fn view_image_tool_does_not_force_original_resolution_with_capability_feat text_elements: Vec::new(), }], final_output_json_schema: None, - cwd: cwd.path().to_path_buf(), + cwd: config.cwd.clone(), approval_policy: AskForApproval::Never, sandbox_policy: SandboxPolicy::DangerFullAccess, model: session_model, @@ -781,7 +832,7 @@ async fn view_image_tool_does_not_force_original_resolution_with_capability_feat .await?; wait_for_event_with_timeout( - &codex, + codex, |event| matches!(event, EventMsg::TurnComplete(_)), Duration::from_secs(10), ) @@ -827,12 +878,13 @@ async fn js_repl_emit_image_attaches_local_image() -> anyhow::Result<()> { .enable(Feature::JsRepl) .expect("test config should allow feature update"); }); + let test = builder.build_remote_aware(&server).await?; let TestCodex { codex, - cwd, + config, session_configured, .. - } = builder.build(&server).await?; + } = &test; let call_id = "js-repl-view-image"; let js_input = r#" @@ -869,7 +921,7 @@ await codex.emitImage(out); text_elements: Vec::new(), }], final_output_json_schema: None, - cwd: cwd.path().to_path_buf(), + cwd: config.cwd.clone(), approval_policy: AskForApproval::Never, sandbox_policy: SandboxPolicy::DangerFullAccess, model: session_model, @@ -883,7 +935,7 @@ await codex.emitImage(out); let mut tool_event = None; wait_for_event_with_timeout( - &codex, + codex, |event| match event { EventMsg::ViewImageToolCall(_) => { tool_event = Some(event.clone()); @@ -946,12 +998,13 @@ async fn js_repl_view_image_requires_explicit_emit() -> anyhow::Result<()> { .enable(Feature::JsRepl) .expect("test config should allow feature update"); }); + let test = builder.build_remote_aware(&server).await?; let TestCodex { codex, - cwd, + config, session_configured, .. - } = builder.build(&server).await?; + } = &test; let call_id = "js-repl-view-image-no-emit"; let js_input = r#" @@ -988,7 +1041,7 @@ console.log(out.type); text_elements: Vec::new(), }], final_output_json_schema: None, - cwd: cwd.path().to_path_buf(), + cwd: config.cwd.clone(), approval_policy: AskForApproval::Never, sandbox_policy: SandboxPolicy::DangerFullAccess, model: session_model, @@ -1002,7 +1055,7 @@ console.log(out.type); let mut tool_event = None; wait_for_event_with_timeout( - &codex, + codex, |event| match event { EventMsg::ViewImageToolCall(_) => { tool_event = Some(event.clone()); @@ -1043,16 +1096,17 @@ async fn view_image_tool_errors_when_path_is_directory() -> anyhow::Result<()> { let server = start_mock_server().await; + let mut builder = test_codex(); + let test = builder.build_remote_aware(&server).await?; let TestCodex { codex, - cwd, + config, session_configured, .. - } = test_codex().build(&server).await?; + } = &test; let rel_path = "assets"; - let abs_path = cwd.path().join(rel_path); - std::fs::create_dir_all(&abs_path)?; + let abs_path = create_workspace_directory(&test, rel_path).await?; let call_id = "view-image-directory"; let arguments = serde_json::json!({ "path": rel_path }).to_string(); @@ -1079,7 +1133,7 @@ async fn view_image_tool_errors_when_path_is_directory() -> anyhow::Result<()> { text_elements: Vec::new(), }], final_output_json_schema: None, - cwd: cwd.path().to_path_buf(), + cwd: config.cwd.clone(), approval_policy: AskForApproval::Never, sandbox_policy: SandboxPolicy::DangerFullAccess, model: session_model, @@ -1091,7 +1145,7 @@ async fn view_image_tool_errors_when_path_is_directory() -> anyhow::Result<()> { }) .await?; - wait_for_event(&codex, |event| matches!(event, EventMsg::TurnComplete(_))).await; + wait_for_event(codex, |event| matches!(event, EventMsg::TurnComplete(_))).await; let req = mock.single_request(); let body_with_tool_output = req.body_json(); @@ -1116,19 +1170,18 @@ async fn view_image_tool_errors_for_non_image_files() -> anyhow::Result<()> { let server = start_mock_server().await; + let mut builder = test_codex(); + let test = builder.build_remote_aware(&server).await?; let TestCodex { codex, - cwd, + config, session_configured, .. - } = test_codex().build(&server).await?; + } = &test; let rel_path = "assets/example.json"; - let abs_path = cwd.path().join(rel_path); - if let Some(parent) = abs_path.parent() { - std::fs::create_dir_all(parent)?; - } - std::fs::write(&abs_path, br#"{ "message": "hello" }"#)?; + let abs_path = + write_workspace_file(&test, rel_path, br#"{ "message": "hello" }"#.to_vec()).await?; let call_id = "view-image-non-image"; let arguments = serde_json::json!({ "path": rel_path }).to_string(); @@ -1155,7 +1208,7 @@ async fn view_image_tool_errors_for_non_image_files() -> anyhow::Result<()> { text_elements: Vec::new(), }], final_output_json_schema: None, - cwd: cwd.path().to_path_buf(), + cwd: config.cwd.clone(), approval_policy: AskForApproval::Never, sandbox_policy: SandboxPolicy::DangerFullAccess, model: session_model, @@ -1167,7 +1220,7 @@ async fn view_image_tool_errors_for_non_image_files() -> anyhow::Result<()> { }) .await?; - wait_for_event(&codex, |event| matches!(event, EventMsg::TurnComplete(_))).await; + wait_for_event(codex, |event| matches!(event, EventMsg::TurnComplete(_))).await; let request = mock.single_request(); assert!( @@ -1198,15 +1251,17 @@ async fn view_image_tool_errors_when_file_missing() -> anyhow::Result<()> { let server = start_mock_server().await; + let mut builder = test_codex(); + let test = builder.build_remote_aware(&server).await?; let TestCodex { codex, - cwd, + config, session_configured, .. - } = test_codex().build(&server).await?; + } = &test; let rel_path = "missing/example.png"; - let abs_path = cwd.path().join(rel_path); + let abs_path = config.cwd.join(rel_path); let call_id = "view-image-missing"; let arguments = serde_json::json!({ "path": rel_path }).to_string(); @@ -1233,7 +1288,7 @@ async fn view_image_tool_errors_when_file_missing() -> anyhow::Result<()> { text_elements: Vec::new(), }], final_output_json_schema: None, - cwd: cwd.path().to_path_buf(), + cwd: config.cwd.clone(), approval_policy: AskForApproval::Never, sandbox_policy: SandboxPolicy::DangerFullAccess, model: session_model, @@ -1245,7 +1300,7 @@ async fn view_image_tool_errors_when_file_missing() -> anyhow::Result<()> { }) .await?; - wait_for_event(&codex, |event| matches!(event, EventMsg::TurnComplete(_))).await; + wait_for_event(codex, |event| matches!(event, EventMsg::TurnComplete(_))).await; let req = mock.single_request(); let body_with_tool_output = req.body_json(); @@ -1322,21 +1377,16 @@ async fn view_image_tool_returns_unsupported_message_for_text_only_model() -> an ) .await; - let TestCodex { codex, cwd, .. } = test_codex() + let mut builder = test_codex() .with_auth(CodexAuth::create_dummy_chatgpt_auth_for_testing()) .with_config(|config| { config.model = Some(model_slug.to_string()); - }) - .build(&server) - .await?; + }); + let test = builder.build_remote_aware(&server).await?; + let TestCodex { codex, config, .. } = &test; let rel_path = "assets/example.png"; - let abs_path = cwd.path().join(rel_path); - if let Some(parent) = abs_path.parent() { - std::fs::create_dir_all(parent)?; - } - let image = ImageBuffer::from_pixel(20, 20, Rgba([255u8, 0, 0, 255])); - image.save(&abs_path)?; + write_workspace_png(&test, rel_path, 20, 20, [255u8, 0, 0, 255]).await?; let call_id = "view-image-unsupported-model"; let arguments = serde_json::json!({ "path": rel_path }).to_string(); @@ -1360,7 +1410,7 @@ async fn view_image_tool_returns_unsupported_message_for_text_only_model() -> an text_elements: Vec::new(), }], final_output_json_schema: None, - cwd: cwd.path().to_path_buf(), + cwd: config.cwd.clone(), approval_policy: AskForApproval::Never, sandbox_policy: SandboxPolicy::DangerFullAccess, model: model_slug.to_string(), @@ -1372,7 +1422,7 @@ async fn view_image_tool_returns_unsupported_message_for_text_only_model() -> an }) .await?; - wait_for_event(&codex, |event| matches!(event, EventMsg::TurnComplete(_))).await; + wait_for_event(codex, |event| matches!(event, EventMsg::TurnComplete(_))).await; let output_text = mock .single_request() @@ -1414,20 +1464,17 @@ async fn replaces_invalid_local_image_after_bad_request() -> anyhow::Result<()> let completion_mock = responses::mount_sse_once(&server, success_response).await; + let mut builder = test_codex(); + let test = builder.build_remote_aware(&server).await?; let TestCodex { codex, - cwd, + config, session_configured, .. - } = test_codex().build(&server).await?; + } = &test; let rel_path = "assets/poisoned.png"; - let abs_path = cwd.path().join(rel_path); - if let Some(parent) = abs_path.parent() { - std::fs::create_dir_all(parent)?; - } - let image = ImageBuffer::from_pixel(1024, 512, Rgba([10u8, 20, 30, 255])); - image.save(&abs_path)?; + let abs_path = write_workspace_png(&test, rel_path, 1024, 512, [10u8, 20, 30, 255]).await?; let session_model = session_configured.model.clone(); @@ -1437,7 +1484,7 @@ async fn replaces_invalid_local_image_after_bad_request() -> anyhow::Result<()> path: abs_path.clone(), }], final_output_json_schema: None, - cwd: cwd.path().to_path_buf(), + cwd: config.cwd.clone(), approval_policy: AskForApproval::Never, sandbox_policy: SandboxPolicy::DangerFullAccess, model: session_model,