mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
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:
@@ -3294,14 +3294,14 @@ impl Session {
|
||||
)]
|
||||
pub(crate) async fn active_turn_context_and_strict_auto_review(
|
||||
&self,
|
||||
) -> Option<(Arc<TurnContext>, Arc<ResolvedStepSettings>, bool)> {
|
||||
) -> Option<(Arc<TurnContext>, Arc<step_context::StepInputs>, bool)> {
|
||||
let active = self.active_turn.lock().await;
|
||||
let active = active.as_ref()?;
|
||||
let task = active.task.as_ref()?;
|
||||
let turn_context = Arc::clone(&task.turn_context);
|
||||
let step_settings = turn_context.current_settings.load_full();
|
||||
let step_inputs = turn_context.next_step_input.load_full();
|
||||
let ts = active.turn_state.lock().await;
|
||||
Some((turn_context, step_settings, ts.strict_auto_review_enabled()))
|
||||
Some((turn_context, step_inputs, ts.strict_auto_review_enabled()))
|
||||
}
|
||||
|
||||
pub(crate) async fn granted_session_permissions(
|
||||
@@ -3695,9 +3695,10 @@ impl Session {
|
||||
required_servers: &[String],
|
||||
required_plugins: &HashSet<String>,
|
||||
) -> CodexResult<Arc<StepContext>> {
|
||||
// Capture once before asynchronous planning; all request consumers
|
||||
// retain this immutable settings version even if the turn is updated.
|
||||
let mut settings = turn_context.current_settings.load_full();
|
||||
// Capture settings and selection together before asynchronous planning.
|
||||
// Existing steps retain this version even if the turn is updated.
|
||||
let inputs = turn_context.next_step_input.load_full();
|
||||
let mut settings = Arc::clone(&inputs.settings);
|
||||
if matches!(
|
||||
turn_context.session_source,
|
||||
SessionSource::SubAgent(SubAgentSource::ThreadSpawn { .. })
|
||||
@@ -3722,8 +3723,8 @@ impl Session {
|
||||
settings.model_info.as_ref(),
|
||||
);
|
||||
let session_telemetry = settings.telemetry(&turn_context.session_telemetry);
|
||||
// Keep selections fixed for the turn while allowing their startup work to finish.
|
||||
let environments = turn_context.environments.refresh_readiness();
|
||||
// Refresh only the captured step selection, without adopting newer inputs.
|
||||
let environments = inputs.environments.refresh_readiness();
|
||||
let (loaded_agents_md, warnings) = self
|
||||
.services
|
||||
.agents_md_manager
|
||||
|
||||
Reference in New Issue
Block a user