Fix Codex exec resume sandbox arg ordering

This commit is contained in:
cc-dan
2026-03-17 03:08:07 +00:00
parent 7c993f1c4a
commit 7ec87714c5
3 changed files with 12 additions and 4 deletions

View File

@@ -73,16 +73,22 @@ function createAgentRuntime(deps) {
}
const runtimeId = getRuntimeSessionId(session);
const args = ['exec'];
if (runtimeId) args.push('resume');
args.push('--json', '--skip-git-repo-check');
const permMode = session.permissionMode || 'yolo';
// `-s/--sandbox` is an option for `codex exec`, but not for `codex exec resume`.
// When resuming, it must appear before the `resume` subcommand, otherwise Codex CLI errors
// with: "unexpected argument '-s' found".
if (runtimeId && permMode === 'plan') {
args.push('-s', 'read-only');
}
if (runtimeId) args.push('resume');
switch (permMode) {
case 'yolo':
args.push('--dangerously-bypass-approvals-and-sandbox');
break;
case 'plan':
args.push('-s', 'read-only');
if (!runtimeId) args.push('-s', 'read-only');
break;
case 'default':
default: