fix: approval issue (#5525)

This commit is contained in:
jif-oai
2025-10-23 11:13:53 +01:00
committed by GitHub
parent 8e291a1706
commit 892eaff46d
3 changed files with 12 additions and 2 deletions

View File

@@ -98,9 +98,9 @@ impl ToolOrchestrator {
"sandbox denied and no retry".to_string(), "sandbox denied and no retry".to_string(),
)); ));
} }
// Under `Never`, do not retry without sandbox; surface a concise message // Under `Never` or `OnRequest`, do not retry without sandbox; surface a concise message
// derived from the actual output (platform-agnostic). // derived from the actual output (platform-agnostic).
if matches!(approval_policy, AskForApproval::Never) { if !tool.wants_no_sandbox_approval(approval_policy) {
let msg = build_never_denied_message_from_output(output.as_ref()); let msg = build_never_denied_message_from_output(output.as_ref());
return Err(ToolError::SandboxDenied(msg)); return Err(ToolError::SandboxDenied(msg));
} }

View File

@@ -17,6 +17,7 @@ use crate::tools::sandboxing::ToolCtx;
use crate::tools::sandboxing::ToolError; use crate::tools::sandboxing::ToolError;
use crate::tools::sandboxing::ToolRuntime; use crate::tools::sandboxing::ToolRuntime;
use crate::tools::sandboxing::with_cached_approval; use crate::tools::sandboxing::with_cached_approval;
use codex_protocol::protocol::AskForApproval;
use codex_protocol::protocol::ReviewDecision; use codex_protocol::protocol::ReviewDecision;
use futures::future::BoxFuture; use futures::future::BoxFuture;
use std::collections::HashMap; use std::collections::HashMap;
@@ -127,6 +128,10 @@ impl Approvable<ApplyPatchRequest> for ApplyPatchRuntime {
.await .await
}) })
} }
fn wants_no_sandbox_approval(&self, policy: AskForApproval) -> bool {
!matches!(policy, AskForApproval::Never)
}
} }
impl ToolRuntime<ApplyPatchRequest, ExecToolCallOutput> for ApplyPatchRuntime { impl ToolRuntime<ApplyPatchRequest, ExecToolCallOutput> for ApplyPatchRuntime {

View File

@@ -121,6 +121,11 @@ pub(crate) trait Approvable<Req> {
} }
} }
/// Decide we can request an approval for no-sandbox execution.
fn wants_no_sandbox_approval(&self, policy: AskForApproval) -> bool {
!matches!(policy, AskForApproval::Never | AskForApproval::OnRequest)
}
fn start_approval_async<'a>( fn start_approval_async<'a>(
&'a mut self, &'a mut self,
req: &'a Req, req: &'a Req,