fix child cwd inheritance for review sessions

This commit is contained in:
Adam Perry
2026-06-12 06:19:44 +00:00
parent aa46f2debf
commit dd8599650c
3 changed files with 15 additions and 1 deletions

View File

@@ -751,7 +751,7 @@ async fn run_guardian_review_session_before_deadline(
guardian_model.as_str(),
guardian_reasoning_effort.clone(),
);
let guardian_config = match guardian_config {
let mut guardian_config = match guardian_config {
Ok(config) => config,
Err(err) => {
return (
@@ -760,6 +760,9 @@ async fn run_guardian_review_session_before_deadline(
);
}
};
if let Some(primary_environment) = turn.environments.primary() {
guardian_config.cwd = primary_environment.cwd.clone();
}
let (session_outcome, session_analytics_result) = Box::pin(
session

View File

@@ -45,6 +45,9 @@ pub(super) async fn spawn_review_thread(
// Build perturn client with the requested model/family.
let mut per_turn_config = (*config).clone();
if let Some(primary_environment) = parent_turn_context.environments.primary() {
per_turn_config.cwd = primary_environment.cwd.clone();
}
per_turn_config.model = Some(model.clone());
per_turn_config.features = review_features.clone();
let tool_mode = model_info.tool_mode.unwrap_or_else(|| {

View File

@@ -796,6 +796,7 @@ async fn review_uses_overridden_cwd_for_base_branch_merge_base() {
run_git(repo_path, &["config", "user.email", "test@example.com"]);
run_git(repo_path, &["config", "user.name", "Test User"]);
std::fs::write(repo_path.join("file.txt"), "hello\n").unwrap();
std::fs::write(repo_path.join("AGENTS.md"), "review repo instructions").unwrap();
run_git(repo_path, &["add", "."]);
run_git(repo_path, &["commit", "-m", "initial"]);
@@ -859,6 +860,13 @@ async fn review_uses_overridden_cwd_for_base_branch_merge_base() {
saw_merge_base_sha,
"expected review prompt to include merge-base sha {head_sha}"
);
assert!(
input
.iter()
.filter_map(|msg| msg["content"][0]["text"].as_str())
.any(|text| text.contains("review repo instructions")),
"expected review child to load instructions from its overridden cwd"
);
let _codex_home_guard = codex_home;
server.verify().await;