Skip to content

Pin the Working Directory of a Scheduled Codex Run

2026-08-24

A reviewer asks where a number came from. The answer you want is a commit and a command. A nightly eval that runs Codex from cron or CI starts wherever the scheduler starts, so relative paths such as results/ can resolve inside another project, and nothing in the output says so. The fix has two parts: pin the directory, then record the provenance of every result.

You need: the Codex CLI and a project that is a Git repository. The check below reads files and edits nothing.

Pin the directory in the command the scheduler runs:

bash
codex exec --cd /srv/research/eval-harness --sandbox read-only \
  "Do not edit anything. Report your working directory, the current Git revision, and the path of README.md relative to that directory."

Run it twice, from two different parent directories, such as your home directory and /tmp. Both runs should report the same directory, the same revision and README.md. If one reports where you launched it, the job still inherits its location; fix that before it gets write access.

Then make the job write a provenance line next to every result, from the shell rather than from the model's answer:

bash
printf '%s\t%s\t%s\t%s\n' "$(pwd)" "$(git rev-parse HEAD)" \
  "$(git status --porcelain | wc -l | tr -d ' ')" "$CMD" >> results/provenance.tsv

The third field counts uncommitted changes. A nonzero count means the number came from code no commit holds, so it cannot be rerun exactly. Have the report generator refuse any row whose provenance is missing or dirty.

OpenAI's non-interactive guide says Codex refuses to run outside a Git repository unless you pass --skip-git-repo-check. That refusal protects the revision field. If a scheduled run stops there, fix the directory; the flag removes the check without changing where the task runs.

What was checked: --cd, --sandbox and --skip-git-repo-check appear in codex exec --help for codex-cli 0.155.1, run on September 20, 2026. The Git requirement comes from OpenAI's documentation, reread on September 30, 2026. The two-directory trial was not run against a live model for this note, so the expected result is what to test for, not a recorded output.

The working directory also decides which AGENTS.md files Codex loads. Honest reports of what produced a result are the theme of Chapter 20.

OpenAI documentation.

Updated . Added the command, a two-directory trial with its expected result, and what was checked.