proposing execpolicy amendment when prompting due to sandbox denial (#7653)

Currently, we only show the “don’t ask again for commands that start
with…” option when a command is immediately flagged as needing approval.
However, there is another case where we ask for approval: When a command
is initially auto-approved to run within sandbox, but it fails to run
inside sandbox, we would like to attempt to retry running outside of
sandbox. This will require a prompt to the user.

This PR addresses this latter case
This commit is contained in:
zhao-oai
2025-12-08 09:55:20 -08:00
committed by GitHub
Unverified
parent cfda44b98b
commit c2bdee0946
4 changed files with 121 additions and 35 deletions
+2 -1
View File
@@ -133,7 +133,8 @@ impl Approvable<ShellRequest> for ShellRuntime {
|| matches!(
req.exec_approval_requirement,
ExecApprovalRequirement::Skip {
bypass_sandbox: true
bypass_sandbox: true,
..
}
)
{
@@ -154,7 +154,8 @@ impl Approvable<UnifiedExecRequest> for UnifiedExecRuntime<'_> {
|| matches!(
req.exec_approval_requirement,
ExecApprovalRequirement::Skip {
bypass_sandbox: true
bypass_sandbox: true,
..
}
)
{
+8
View File
@@ -95,6 +95,9 @@ pub(crate) enum ExecApprovalRequirement {
/// The first attempt should skip sandboxing (e.g., when explicitly
/// greenlit by policy).
bypass_sandbox: bool,
/// Proposed execpolicy amendment to skip future approvals for similar commands
/// Only applies if the command fails to run in sandbox and codex prompts the user to run outside the sandbox.
proposed_execpolicy_amendment: Option<ExecPolicyAmendment>,
},
/// Approval required for this tool call.
NeedsApproval {
@@ -114,6 +117,10 @@ impl ExecApprovalRequirement {
proposed_execpolicy_amendment: Some(prefix),
..
} => Some(prefix),
Self::Skip {
proposed_execpolicy_amendment: Some(prefix),
..
} => Some(prefix),
_ => None,
}
}
@@ -140,6 +147,7 @@ pub(crate) fn default_exec_approval_requirement(
} else {
ExecApprovalRequirement::Skip {
bypass_sandbox: false,
proposed_execpolicy_amendment: None,
}
}
}