Keep step settings and approval environments consistent (#46556)

## Why

Background processes can outlive their launching turn. Their approval reviews need the originating environment's filesystem restrictions, even when the active turn uses a different environment. Remote restrictions must also be resolved using executor paths rather than the local filesystem.

## What changed

- Capture settings and environment selections together in `StepInputs`. Preserve the captured selection during active model updates while allowing environment startup to finish.
- Carry environment IDs into Guardian network and `execve` requests, and use the owning process's environment with current review settings. Refresh environment readiness for network requests that fall back to the active turn.
- Resolve remote denied paths and globs using the executor's policy context. Decline automatic approval when the request's environment is unavailable or an explicitly denied temporary directory cannot be resolved.

## Testing

Add regression coverage for active model updates retaining their environment while the next turn adopts a new selection, background approvals using their owning environment, newly ready network environments, and remote denied paths and globs, including Windows paths and missing temporary-directory metadata.

GitOrigin-RevId: b620d4b030c597a4f430fe0500864fa5469db3d4
This commit is contained in:
sayan-oai
2026-09-19 01:27:26 +00:00
committed by copyberry
parent 328feb0c29
commit c7828dd010
44 changed files with 872 additions and 255 deletions
+1 -1
View File
@@ -405,7 +405,7 @@ impl LocalAgentControl {
"cannot resume multi-agent v2 child {thread_id} with the current parent settings"
))
})?;
Some((parent, turn.environments.clone()))
Some((parent, turn.initial_environments.clone()))
} else {
None
};
+3 -3
View File
@@ -900,7 +900,7 @@ async fn check_v2_agent_reload(route: V2ReloadRoute) {
.expect("known v2 agent should reload"),
V2ReloadRoute::NestedParent => {
let environment = parent_turn
.environments
.initial_environments
.primary()
.expect("parent environment");
let mut owner_config = environment.config().clone();
@@ -950,12 +950,12 @@ async fn check_v2_agent_reload(route: V2ReloadRoute) {
let reloaded_turn = reloaded_child.session.new_default_turn().await;
assert_eq!(
(
reloaded_turn.environments.to_selections(),
reloaded_turn.initial_environments.to_selections(),
reloaded_turn.permission_profile(),
reloaded_child.client_mcp_extensions(),
),
(
parent_turn.environments.to_selections(),
parent_turn.initial_environments.to_selections(),
parent_turn.permission_profile(),
client_mcp_extensions,
),