Normalize Guardian review cwd reuse keys (#34824)

## What changed

- Store the spawned session's working directory as a `PathUri` in
  `GuardianReviewSessionReuseKey` so reuse comparisons use its canonical URI
  representation.
- Assert that the reuse key contains the converted working directory.

GitOrigin-RevId: 68d440a37ebb310c610dabbb3373ed0ceff88dfa
This commit is contained in:
Adam Perry @ OpenAI
2026-07-22 20:45:37 +00:00
committed by copyberry
parent 7fd7a2f9a2
commit bbfc3f0152

View File

@@ -50,7 +50,7 @@ use crate::session::turn_context::TurnContext;
use codex_config::types::McpServerConfig;
use codex_features::Feature;
use codex_model_provider_info::ModelProviderInfo;
use codex_utils_absolute_path::AbsolutePathBuf;
use codex_utils_path_uri::PathUri;
use super::GUARDIAN_REVIEWER_NAME;
use super::GuardianApprovalRequest;
@@ -168,7 +168,7 @@ struct GuardianReviewSessionReuseKey {
base_instructions: Option<String>,
user_instructions: Option<UserInstructions>,
compact_prompt: Option<String>,
cwd: AbsolutePathBuf,
cwd: PathUri,
mcp_servers: Constrained<HashMap<String, McpServerConfig>>,
codex_linux_sandbox_exe: Option<PathBuf>,
main_execve_wrapper_exe: Option<PathBuf>,
@@ -196,7 +196,7 @@ impl GuardianReviewSessionReuseKey {
base_instructions: spawn_config.base_instructions.clone(),
user_instructions,
compact_prompt: spawn_config.compact_prompt.clone(),
cwd: spawn_config.cwd.clone(),
cwd: PathUri::from_abs_path(&spawn_config.cwd),
mcp_servers: spawn_config.mcp_servers.clone(),
codex_linux_sandbox_exe: spawn_config.codex_linux_sandbox_exe.clone(),
main_execve_wrapper_exe: spawn_config.main_execve_wrapper_exe.clone(),
@@ -1286,6 +1286,10 @@ mod tests {
/*user_instructions*/ None,
);
assert_eq!(
cached_reuse_key.cwd,
PathUri::from_abs_path(&cached_spawn_config.cwd)
);
assert_ne!(cached_reuse_key, next_reuse_key);
assert_eq!(
cached_reuse_key,