@@ -1453,6 +1453,44 @@ mod tests {
14531453 "{progress_log}"
14541454 ) ;
14551455 }
1456+
1457+ #[ test]
1458+ fn codex_autoflags_use_current_approval_and_sandbox_flags ( ) {
1459+ let mut parts = Vec :: new ( ) ;
1460+
1461+ apply_claude_autoflags ( "codex" , & mut parts) ;
1462+
1463+ assert_eq ! (
1464+ parts,
1465+ [
1466+ "--ask-for-approval" ,
1467+ "never" ,
1468+ "--sandbox" ,
1469+ "workspace-write"
1470+ ]
1471+ ) ;
1472+ assert ! (
1473+ !parts. iter( ) . any( |part| part == "--full-auto" ) ,
1474+ "obsolete codex flag must not be injected"
1475+ ) ;
1476+ }
1477+
1478+ #[ test]
1479+ fn codex_autoflags_respect_operator_supplied_policy ( ) {
1480+ let mut parts = vec ! [
1481+ "--ask-for-approval" . to_string( ) ,
1482+ "on-request" . to_string( ) ,
1483+ "--sandbox" . to_string( ) ,
1484+ "read-only" . to_string( ) ,
1485+ ] ;
1486+
1487+ apply_claude_autoflags ( "codex" , & mut parts) ;
1488+
1489+ assert_eq ! (
1490+ parts,
1491+ [ "--ask-for-approval" , "on-request" , "--sandbox" , "read-only" ]
1492+ ) ;
1493+ }
14561494}
14571495
14581496#[ allow( dead_code) ]
@@ -2699,20 +2737,22 @@ fn apply_claude_autoflags(command: &str, parts: &mut Vec<String>) {
26992737 }
27002738 "codex" => {
27012739 // Codex's interactive REPL gates writes / shell calls behind
2702- // an approval prompt unless we opt out. --full-auto runs in
2703- // workspace-write sandbox with --ask-for-approval=never, the
2704- // closest equivalent to claude's bypassPermissions . Only
2705- // inject when the operator hasn't already set an approval
2706- // or sandbox flag (so power users keep control).
2740+ // an approval prompt unless we opt out. Current Codex exposes
2741+ // this as explicit approval + sandbox flags; older --full-auto
2742+ // releases are not universally available . Only inject when the
2743+ // operator hasn't already set an approval or sandbox flag (so
2744+ // power users keep control).
27072745 let already_set = parts. iter ( ) . any ( |a| {
2708- a == "--full-auto"
2709- || a == "--ask-for-approval"
2746+ a == "--ask-for-approval"
27102747 || a. starts_with ( "--ask-for-approval=" )
27112748 || a == "--sandbox"
27122749 || a. starts_with ( "--sandbox=" )
27132750 } ) ;
27142751 if !already_set {
2715- parts. push ( "--full-auto" . to_string ( ) ) ;
2752+ parts. push ( "--ask-for-approval" . to_string ( ) ) ;
2753+ parts. push ( "never" . to_string ( ) ) ;
2754+ parts. push ( "--sandbox" . to_string ( ) ) ;
2755+ parts. push ( "workspace-write" . to_string ( ) ) ;
27162756 }
27172757 }
27182758 _ => { }
@@ -2787,8 +2827,8 @@ fn derive_reviewer_command(explicit: Option<&str>, _repo_root: &std::path::Path)
27872827 // Default: bare `codex`. drive_agent spawns it in a real PTY,
27882828 // pastes the prompt as keystrokes, captures the response via the
27892829 // same file-handoff side channel claude uses. apply_claude_autoflags
2790- // adds --full-auto (codex's equivalent of claude's bypassPermissions)
2791- // so the loop doesn't gate on an approval dialog.
2830+ // adds supported Codex approval/sandbox flags so the loop doesn't gate
2831+ // on an approval dialog.
27922832 //
27932833 // The bundled scripts/wrappers/codex.sh shim still exists for users
27942834 // who explicitly opt in (it uses `codex exec` non-interactive); the
0 commit comments