From a59a419afa3492c58eb3d4865bf8ab1fd8c68330 Mon Sep 17 00:00:00 2001 From: "Adam Perry @ OpenAI" Date: Wed, 22 Jul 2026 18:31:19 +0000 Subject: [PATCH] Use path URIs in shell approval keys (#34806) ## What changed - Store the shell approval key's `cwd` as a `PathUri`, matching the URI representation used by approval actions. - Extend the approval-key test to verify both the URI-based working directory and environment scoping. ## Testing - Added `approval_key_uses_path_uri_and_includes_environment_id`. GitOrigin-RevId: 4d7ba1a2e652f4ffe317242f52beb33513b01e6a --- codex-rs/core/src/tools/runtimes/shell.rs | 4 ++-- codex-rs/core/src/tools/runtimes/shell_tests.rs | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/codex-rs/core/src/tools/runtimes/shell.rs b/codex-rs/core/src/tools/runtimes/shell.rs index 1d25672e92..ac8e020599 100644 --- a/codex-rs/core/src/tools/runtimes/shell.rs +++ b/codex-rs/core/src/tools/runtimes/shell.rs @@ -95,7 +95,7 @@ pub struct ShellRuntime { pub(crate) struct ApprovalKey { environment_id: String, command: Vec, - cwd: AbsolutePathBuf, + cwd: PathUri, sandbox_permissions: SandboxPermissions, additional_permissions: Option, } @@ -130,7 +130,7 @@ impl Approvable for ShellRuntime { vec![ApprovalKey { environment_id: req.turn_environment.environment_id.clone(), command: canonicalize_command_for_approval(&req.command), - cwd: req.cwd.clone(), + cwd: PathUri::from_abs_path(&req.cwd), sandbox_permissions: req.sandbox_permissions, additional_permissions: req.additional_permissions.clone(), }] diff --git a/codex-rs/core/src/tools/runtimes/shell_tests.rs b/codex-rs/core/src/tools/runtimes/shell_tests.rs index 9f070490ad..7ae93ab918 100644 --- a/codex-rs/core/src/tools/runtimes/shell_tests.rs +++ b/codex-rs/core/src/tools/runtimes/shell_tests.rs @@ -1,10 +1,11 @@ use super::*; use codex_exec_server::Environment; use codex_utils_path_uri::PathUri; +use pretty_assertions::assert_eq; use std::sync::Arc; #[tokio::test] -async fn approval_key_includes_environment_id() { +async fn approval_key_uses_path_uri_and_includes_environment_id() { let cwd = AbsolutePathBuf::try_from(std::env::current_dir().expect("read current dir")) .expect("current dir is absolute"); let mut request = ShellRequest { @@ -36,6 +37,16 @@ async fn approval_key_includes_environment_id() { }; let runtime = ShellRuntime::for_shell_command(ShellRuntimeBackend::ShellCommandClassic); let original_key = runtime.approval_keys(&request); + assert_eq!( + original_key, + vec![ApprovalKey { + environment_id: "remote".to_string(), + command: request.command.clone(), + cwd: PathUri::from_abs_path(&cwd), + sandbox_permissions: request.sandbox_permissions, + additional_permissions: request.additional_permissions.clone(), + }] + ); request.turn_environment.environment_id = "other".to_string(); let other_key = runtime.approval_keys(&request);