Skip to content

Commit df688f8

Browse files
authored
Use --dangerously-bypass-approvals-and-sandbox for codex node execution (#28)
The -c sandbox_mode config override does not change codex exec's effective sandbox (still tried bwrap -> 'Creating new namespace failed' in the node). Switch to the documented --dangerously-bypass-approvals-and-sandbox flag (skips inner sandbox + approvals), inserted after the exec subcommand. Bump 0.4.39.
1 parent c0dd684 commit df688f8

2 files changed

Lines changed: 20 additions & 21 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "animus-workflow-runner-default"
3-
version = "0.4.38"
3+
version = "0.4.39"
44
edition = "2021"
55
description = "Reference workflow_runner plugin for Animus v0.5 (stdio JSON-RPC + direct-execute CLI; replaces in-tree workflow-runner-v2)"
66
license = "Elastic-2.0"

src/phase_environment.rs

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -788,21 +788,23 @@ fn apply_reasoning_effort(tool: &str, args: Vec<String>, reasoning_effort: Optio
788788
/// it can run commands — the codex analogue of claude's `bypassPermissions`
789789
/// default. `ensure_codex_config_override` upserts, so this wins over any earlier
790790
/// `approval_policy` set from a permission mode.
791-
fn apply_codex_node_sandbox(tool: &str, args: Vec<String>) -> Vec<String> {
791+
fn apply_codex_node_sandbox(tool: &str, mut args: Vec<String>) -> Vec<String> {
792792
if !tool.trim().eq_ignore_ascii_case("codex") {
793793
return args;
794794
}
795-
let mut contract = serde_json::json!({ "cli": { "launch": { "args": args } } });
796-
animus_runtime_shared::inject_codex_config_overrides_list(
797-
&mut contract,
798-
"codex",
799-
&["sandbox_mode=\"danger-full-access\"".to_string(), "approval_policy=\"never\"".to_string()],
800-
);
801-
contract
802-
.pointer("/cli/launch/args")
803-
.and_then(Value::as_array)
804-
.map(|args| args.iter().filter_map(Value::as_str).map(ToOwned::to_owned).collect())
805-
.unwrap_or_default()
795+
const BYPASS: &str = "--dangerously-bypass-approvals-and-sandbox";
796+
if args.iter().any(|arg| arg == BYPASS) {
797+
return args;
798+
}
799+
// A `-c sandbox_mode=...` config override does NOT change `codex exec`'s
800+
// effective sandbox — it still tried bwrap and failed to create a namespace
801+
// in the node. The documented flag for an externally-sandboxed host skips
802+
// both the inner sandbox and approval prompts. Place it right after the
803+
// `exec` subcommand so codex parses it as an exec flag; fall back to the
804+
// front when there is no explicit subcommand.
805+
let insert_at = args.iter().position(|arg| arg == "exec").map(|index| index + 1).unwrap_or(0);
806+
args.insert(insert_at, BYPASS.to_string());
807+
args
806808
}
807809

808810
/// Strip the machine-output flags from a launch argv so the command emits plain
@@ -1953,22 +1955,19 @@ environment_routing:
19531955
// can't exec any shell (even a read-only `git diff`).
19541956
let request = sample_request("codex");
19551957
let (command, _stdin) = harness_command_for_request(Path::new("."), &request).expect("codex builds");
1956-
let joined = command.args.join(" ");
19571958
assert!(
1958-
joined.contains("sandbox_mode=\"danger-full-access\""),
1959+
command.args.iter().any(|arg| arg == "--dangerously-bypass-approvals-and-sandbox"),
19591960
"codex node argv disables the inner sandbox: {:?}",
19601961
command.args
19611962
);
1962-
assert!(
1963-
joined.contains("approval_policy=\"never\""),
1964-
"codex node argv auto-approves: {:?}",
1965-
command.args
1966-
);
19671963

19681964
// A non-codex tool is untouched.
19691965
let claude = sample_request("claude");
19701966
let (claude_cmd, _s) = harness_command_for_request(Path::new("."), &claude).expect("claude builds");
1971-
assert!(!claude_cmd.args.join(" ").contains("sandbox_mode"), "claude gets no codex sandbox flag");
1967+
assert!(
1968+
!claude_cmd.args.iter().any(|arg| arg == "--dangerously-bypass-approvals-and-sandbox"),
1969+
"claude gets no codex sandbox flag"
1970+
);
19721971
}
19731972

19741973
#[test]

0 commit comments

Comments
 (0)