mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Use issuing step settings for approval decisions (#40821)
## Why Tool actions and approval retries can outlive the step that issued them. If approval handling reads newer turn settings, a delayed action can use the wrong approval policy or reviewer. ## What changed - Capture the approval policy and reviewer in `GuardianReviewContext` from the issuing step. - Use step settings for command, patch, permission, sandbox-retry, and remote-network approval decisions. - Use the active task's published settings for background network approvals and long-lived Unix shell interception. - Preserve explicit MCP reviewer overrides. ## Testing Added regression coverage for permission requests, same-turn network policy changes, delayed commands after a new turn starts, sandbox retries, patch policy selection, and MCP reviewer overrides. GitOrigin-RevId: b7e84a2e1e79a71502272b15b5ef5b0e5643f8b0
This commit is contained in:
1 parent
21c58c90f2
commit
a26f1806a4
16 files changed
+671
-60
No files matched your search
@@ -564,7 +564,7 @@ async fn execute_verified_patch(
|
||||
.await
|
||||
.unwrap_or_else(|_| patch_permissions_without_path_matching(&action));
|
||||
let apply = apply_patch::prepare_apply_patch(
|
||||
tool_ctx.step_context.turn.as_ref(),
|
||||
&tool_ctx.step_context,
|
||||
&turn_environment,
|
||||
&file_system_sandbox_policy,
|
||||
action,
|
||||
@@ -595,13 +595,7 @@ async fn execute_verified_patch(
|
||||
let mut orchestrator = ToolOrchestrator::new();
|
||||
let mut runtime = ApplyPatchRuntime::new();
|
||||
let result = orchestrator
|
||||
.run(
|
||||
&mut runtime,
|
||||
&request,
|
||||
&tool_ctx,
|
||||
tool_ctx.step_context.turn.as_ref(),
|
||||
tool_ctx.step_context.turn.approval_policy(),
|
||||
)
|
||||
.run(&mut runtime, &request, &tool_ctx)
|
||||
.await
|
||||
.map(|result| result.output);
|
||||
let (result, delta) = match result {
|
||||
|
||||
@@ -276,17 +276,13 @@ impl ExecCommandHandler {
|
||||
|
||||
// Sticky turn permissions have already been approved, so they should
|
||||
// continue through the normal exec approval flow for the command.
|
||||
let approval_policy = context.step_context.settings.approval_policy();
|
||||
if effective_additional_permissions
|
||||
.sandbox_permissions
|
||||
.requests_sandbox_override()
|
||||
&& !effective_additional_permissions.permissions_preapproved
|
||||
&& prompt_is_rejected_by_policy(
|
||||
context.step_context.turn.approval_policy(),
|
||||
/*prompt_is_rule*/ false,
|
||||
)
|
||||
.is_some()
|
||||
&& prompt_is_rejected_by_policy(approval_policy, /*prompt_is_rule*/ false).is_some()
|
||||
{
|
||||
let approval_policy = context.step_context.turn.approval_policy();
|
||||
manager.release_process_id(process_id).await;
|
||||
return Err(FunctionCallError::RespondToModel(format!(
|
||||
"approval policy is {approval_policy:?}; reject command — you cannot ask for escalated permissions if the approval policy is {approval_policy:?}"
|
||||
@@ -302,7 +298,7 @@ impl ExecCommandHandler {
|
||||
|| {
|
||||
normalize_and_validate_additional_permissions(
|
||||
additional_permissions_allowed,
|
||||
context.step_context.turn.approval_policy(),
|
||||
approval_policy,
|
||||
effective_additional_permissions.sandbox_permissions,
|
||||
effective_additional_permissions.additional_permissions,
|
||||
effective_additional_permissions.permissions_preapproved,
|
||||
|
||||
Reference in new issue
Block a user