Back to AI Q&A
Does codex exec not modify files in CI? Read-only is the default key

Does codex exec not modify files in CI? Read-only is the default key

AI Q&A Admin 1 views

codex exec In CI, it can analyze code without making changes; first check the sandbox: non-interactive mode is read-only by default. When it needs to generate patches or modify workspaces, explicitly pass in the --sandbox workspace-write and ensure the boot directory is a checked Git repository.

How to write the minimum writable command

codex exec \  --sandbox workspace-write \  -C "$GITHUB_WORKSPACE" \  "运行测试,修复失败项,只修改必要文件,然后重新运行测试"

workspace-write Only allow writing to the current workspace, which does not mean controlling the entire runner. Do not switch to --yolo or danger-full-access just because of a single failure; Permissions are only expanded when external isolation is strictly separated and the task truly needs it. The --full-auto in the old script is already a compatibility parameter; the new pipeline should declare the sandbox directly.

Still haven't changed the documents, check these three locations

  1. Warehouse check failure: Confirm checkout is successful, then check pwd and git status. Secure non-warehouse temporary directories can use --skip-git-repo-check.
  2. Commands require interactive approval: CI cannot pop up a new approval window, and actions requiring temporary authorization will fail and return an error. Sandboxes and approval policies should be set in advance.
  3. The prompt only requires analysis: clearly state "modify file, run validation, keep diff." After finishing, check Git diff or generate patch artifact; don't just look at the final text.

Let the pipeline get parsable results

Use JSONL when you need to consume a full event stream:

codex exec --json "检查仓库并给出风险列表" > codex-events.jsonl

Just write to the file with -o when answering the final answer; Use --output-schema when fields need to be fixed. Authentication should also minimize exposure: inject CODEX_API_KEY only at the codex exec execution step, and do not let the entire job, dependency scripts, or untrusted code read the key.

Recommended Tools

More