This commit is contained in:
jif-oai
2025-10-15 11:49:55 +01:00
parent 1e2f6f21e2
commit 53f07c304b
2 changed files with 22 additions and 16 deletions
+20 -13
View File
@@ -95,7 +95,7 @@ pub async fn process_exec_tool_call(
sandbox_cwd,
codex_linux_sandbox_exe.as_ref(),
)
.map_err(sandbox_launch_error_to_codex)?;
.map_err(CodexErr::from)?;
execute_sandbox_launch(params, launch, sandbox_type, sandbox_policy, stdout_stream).await
}
@@ -171,18 +171,6 @@ fn finalize_exec_result(
}
}
pub(crate) fn sandbox_launch_error_to_codex(err: SandboxLaunchError) -> CodexErr {
match err {
SandboxLaunchError::MissingCommandLine => CodexErr::Io(io::Error::new(
io::ErrorKind::InvalidInput,
"command args are empty",
)),
SandboxLaunchError::MissingLinuxSandboxExecutable => {
CodexErr::LandlockSandboxExecutableNotProvided
}
}
}
async fn spawn_with_launch(
params: ExecParams,
launch: SandboxLaunch,
@@ -221,6 +209,25 @@ async fn spawn_with_launch(
exec(updated_params, sandbox_policy, stdout_stream).await
}
pub(crate) mod errors {
use super::CodexErr;
use super::SandboxLaunchError;
impl From<SandboxLaunchError> for CodexErr {
fn from(err: SandboxLaunchError) -> Self {
match err {
SandboxLaunchError::MissingCommandLine => CodexErr::Io(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
"command args are empty",
)),
SandboxLaunchError::MissingLinuxSandboxExecutable => {
CodexErr::LandlockSandboxExecutableNotProvided
}
}
}
}
}
/// We don't have a fully deterministic way to tell if our command failed
/// because of the sandbox - a command in the user's zshrc file might hit an
/// error, but the command itself might fail or succeed for other reasons.
+2 -3
View File
@@ -16,7 +16,6 @@ use crate::exec::SandboxType;
use crate::exec::StdoutStream;
use crate::exec::StreamOutput;
use crate::exec::execute_sandbox_launch;
use crate::exec::sandbox_launch_error_to_codex;
use crate::executor::errors::ExecError;
use crate::executor::sandbox::RetrySandboxContext;
use crate::executor::sandbox::SandboxDecision;
@@ -229,7 +228,7 @@ impl Executor {
let sandbox_policy = plan.config().sandbox_policy.clone();
let initial_launch = plan
.initial_launch()
.map_err(|err| ExecError::Codex(sandbox_launch_error_to_codex(err)))?;
.map_err(|err| ExecError::Codex(err.into()))?;
let first_attempt = execute_sandbox_launch(
plan.request().params.clone(),
initial_launch,
@@ -252,7 +251,7 @@ impl Executor {
{
let retry_launch = plan
.retry_launch()
.map_err(|err| ExecError::Codex(sandbox_launch_error_to_codex(err)))?;
.map_err(|err| ExecError::Codex(err.into()))?;
execute_sandbox_launch(
plan.request().params.clone(),
retry_launch,