Skip to content

Commit a8ed762

Browse files
jif-oaiJeffCarpenter
authored andcommitted
fix: approval issue (openai#5525)
1 parent 64d3db8 commit a8ed762

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

codex-rs/core/src/tools/orchestrator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ impl ToolOrchestrator {
9898
"sandbox denied and no retry".to_string(),
9999
));
100100
}
101-
// Under `Never`, do not retry without sandbox; surface a concise message
101+
// Under `Never` or `OnRequest`, do not retry without sandbox; surface a concise message
102102
// derived from the actual output (platform-agnostic).
103-
if matches!(approval_policy, AskForApproval::Never) {
103+
if !tool.wants_no_sandbox_approval(approval_policy) {
104104
let msg = build_never_denied_message_from_output(output.as_ref());
105105
return Err(ToolError::SandboxDenied(msg));
106106
}

codex-rs/core/src/tools/runtimes/apply_patch.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use crate::tools::sandboxing::ToolCtx;
1717
use crate::tools::sandboxing::ToolError;
1818
use crate::tools::sandboxing::ToolRuntime;
1919
use crate::tools::sandboxing::with_cached_approval;
20+
use codex_protocol::protocol::AskForApproval;
2021
use codex_protocol::protocol::ReviewDecision;
2122
use futures::future::BoxFuture;
2223
use std::collections::HashMap;
@@ -127,6 +128,10 @@ impl Approvable<ApplyPatchRequest> for ApplyPatchRuntime {
127128
.await
128129
})
129130
}
131+
132+
fn wants_no_sandbox_approval(&self, policy: AskForApproval) -> bool {
133+
!matches!(policy, AskForApproval::Never)
134+
}
130135
}
131136

132137
impl ToolRuntime<ApplyPatchRequest, ExecToolCallOutput> for ApplyPatchRuntime {

codex-rs/core/src/tools/sandboxing.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ pub(crate) trait Approvable<Req> {
121121
}
122122
}
123123

124+
/// Decide we can request an approval for no-sandbox execution.
125+
fn wants_no_sandbox_approval(&self, policy: AskForApproval) -> bool {
126+
!matches!(policy, AskForApproval::Never | AskForApproval::OnRequest)
127+
}
128+
124129
fn start_approval_async<'a>(
125130
&'a mut self,
126131
req: &'a Req,

0 commit comments

Comments
 (0)