Grant Codex project trust before a headless exec

John Burns

Two isolated homes saw the same checkout. The checkout held a .codex/config.toml that named a model the public catalog does not ship, and an MCP server whose command appends one line to a file outside the checkout. On Codex CLI 0.163.0, codex exec --sandbox workspace-write loaded that model name, started that command, and wrote trust_level = "trusted" for the checkout. On 0.169.0, the same flags printed a warning, left the model name out of the event stream, did not start the command, and did not create config.toml. The later login failed in both homes. The failure is not the difference. The difference is what ran before it.

That split is the 0.169.0 contract, measured on 14 November 2026, US Eastern, against a checkout that had never been trusted. The release note says codex exec keeps project configuration and MCP servers disabled in untrusted directories, even with --sandbox workspace-write, and that --trust saves project trust for current and future chats, including MCP commands outside the sandbox. The note is accurate. It does not say what 0.163.0 writes when the model call never succeeds, which sandbox mode still skips the project file, or that an explicit untrusted value survives the new flag.

The two binaries and the project file

The installed binary was codex-cli 0.163.0. The comparison binary was codex-cli 0.169.0, taken from the npm package @openai/codex@0.169.0 for linux/amd64 musl and left outside the install prefix. Neither binary was logged in. Each decisive run used its own CODEX_HOME. The operator home was not the directory under test. No credential file was copied in.

The checkout was a new git repository. Its project file was:

model = "project-marker-model"

[mcp_servers.probe]
command = "<probe>"
startup_timeout_sec = 5

<probe> is a shell script in the checkout. It appends a UTC timestamp and its process id to <sentinel>, a path outside the checkout, then sleeps. A line in that file means the MCP command started. It does not mean the server spoke MCP. The script never reads a request. A missing line means this process did not start that command.

The prompt was the literal say hi. It was not a coding task, and no model reply was accepted. Both versions that reached the API returned 401 Unauthorized, because the isolated home had no bearer token. Runs that reached that retry were stopped during it, or left to exit 1. A 401 is the expected end of an unauthenticated turn. It is not evidence that project configuration was skipped.

What workspace-write loaded on 0.163.0

codex exec --help on 0.163.0 has no --trust flag. Passing --trust exited 2 with unexpected argument '--trust'. codex review --help rejected the same flag. There is no flag on this binary that means the grant 0.169.0 added.

The workspace-write run was:

CODEX_HOME=<codex-home> codex exec --ephemeral --sandbox workspace-write --color never --json -C <project> 'say hi'

The second JSON event named the project model:

Model metadata for `project-marker-model` not found. Defaulting to fallback metadata; this can degrade performance and cause issues.

<sentinel> gained one line, stamped 2026-11-15T04:08:38Z. The command had written outside the checkout while the turn was still failing login. <codex-home>/config.toml contained:

[projects."<project>"]
trust_level = "trusted"

--ephemeral was set. The trust table was still written. A failed login did not roll it back. The process was stopped during the 401 retries, and the table was already on disk.

The same binary with --sandbox read-only, and a run that omitted --sandbox, did not print the project model name, did not create <sentinel>, and did not create config.toml. On 0.163.0 the project file is not loaded merely because the directory is a git checkout. It is loaded when the sandbox mode is workspace-write. That is the path the 0.169.0 note is closing. A job that already passes --sandbox read-only is not the case this comparison caught.

What 0.169.0 leaves disabled

The same workspace-write command, pointed at the 0.169.0 binary and a fresh home, printed this on stderr before the login errors:

warning: Untrusted project-local configuration is disabled. Run `codex exec --trust` to allow project configuration and MCP servers for this and future chats in the project, including MCP commands outside the sandbox. Explicitly untrusted projects must have their trust setting updated first.

The JSON stream started a thread and a turn. It did not mention project-marker-model. <sentinel> was not created. <codex-home>/config.toml was not created. The 401 still arrived. A wrapper that treats a 401 as “the project was not trusted, so nothing local ran” is right for this binary and wrong for 0.163.0. On 0.163.0 the local command had already run by the time the 401 was printed.

The warning is the line to require in a job log when the checkout is supposed to stay untrusted. Absence of the project model name is the second check. Absence of the MCP command’s side effect is the third. Exit status will not do this job. Both the 0.163.0 workspace-write run and the disabled 0.169.0 run were still in the login retry when they were stopped, and a full run of either exits 1 on the missing token.

The grant –trust writes

--trust is on codex exec and on codex review in 0.169.0. The exec help text says it saves trust for this project and future chats, including MCP commands outside the sandbox, persists even with --ephemeral, and does not override an explicitly untrusted project.

A fresh home, with --trust --ephemeral --sandbox workspace-write, did not print the disable warning. The JSON stream named project-marker-model. <sentinel> gained a line stamped 2026-11-15T04:08:55Z. config.toml held the same trust_level = "trusted" table 0.163.0 had written by itself. The flag is the explicit form of the write the older sandbox mode was doing as a side effect.

A second exec in that same home, without --trust, still named the project model and still started the probe. Stderr had no disable warning. The grant is not a one-shot override. It is a row in the user config, and a later headless run reads it.

That is the operational change for a CI job. On 0.169.0, --sandbox workspace-write is the sandbox for commands the model runs after it is connected. It is not permission to start the checkout’s MCP servers, and it is not permission to keep that permission for the next job. If the job needs the project file, pass --trust once, then confirm the row. If the job must not start those servers, do not pass --trust, and do not reuse a home that already has the row.

The two ways the grant refuses

--trust and --ignore-user-config together exited 1 before any probe line and before any config.toml was created. Stderr was:

Error: --trust cannot be combined with --ignore-user-config: saved project trust decisions must be checked

The flag cannot grant trust while also refusing to read the file where an older refusal would be stored. A job that sets --ignore-user-config to keep a shared home from leaking into the run cannot also pass --trust and expect the project MCP servers to start. Those two switches are a conflict, not a belt and suspenders.

An explicit refusal is the other stop. A home whose config.toml already contained trust_level = "untrusted" for the checkout was given --trust. Exec exited 1. The probe did not start. The value in the file was still untrusted. The error was:

Error: <project> is marked as untrusted. Update its trust setting first.

codex review --trust, run in that checkout with the same home, exited 1 with the same sentence. The probe did not start. The flag is not a force. A checkout marked untrusted stays untrusted until something edits that row. The help text says the flag does not override an explicitly untrusted project. The file after the failed flag is the check, not the help text alone.

The token is lowercase. This run wrote and matched trusted and untrusted. It did not try Trusted, UNTRUSTED, or a missing value. Do not assume another spelling is the same row.

Verify the grant before the job

Before a headless exec against a checkout you do not maintain, print the project table and the warning, and do not infer either from the sandbox flag.

On 0.169.0, a checkout with no saved row should produce the disable warning, should not name a model that exists only in .codex/config.toml, and should not start that file’s MCP commands. A checkout you intend to trust should be granted with --trust, then the user config should contain trust_level = "trusted" for that path. A later run without the flag should still load the project model name. A checkout marked untrusted should make both codex exec --trust and codex review --trust exit 1, leave the value unchanged, and leave the MCP command unstarted.

On 0.163.0, none of those checks exist as a flag. --sandbox workspace-write is enough to load the project file, start its MCP command outside the checkout, and record the checkout as trusted, including when --ephemeral is set and the model call ends in 401. Upgrading the binary does not delete a trusted row an older run already wrote. Read config.toml after the upgrade. A row left behind is the grant, and 0.169.0 will honor it without --trust.

This comparison did not complete a model turn, did not exercise a real MCP handshake, and did not send a prompt that a connected model could have answered. The measured boundary is earlier than a reply: which binary starts the project command, which one writes the trust row, and which refusal leaves that row alone.

Sources

  • Codex CLI 0.163.0, codex --version, Linux x86_64, 14 November 2026 US Eastern. Isolated CODEX_HOME. No auth file. codex exec --sandbox workspace-write loaded project-marker-model, started the probe, and wrote trust_level = "trusted". --sandbox read-only, and a run that omitted --sandbox, did not. --trust was an unexpected argument on exec and review.
  • Codex CLI 0.169.0 from npm @openai/codex@0.169.0, linux/amd64 musl, not copied over the installed binary. Same date, same checkout, new homes. Workspace-write without --trust printed the disable warning and did not load the project model or start the probe. --trust --ephemeral wrote the trust row and started the probe. A later exec without --trust still loaded the project model. --trust --ignore-user-config exited 1 with the combination error. An existing untrusted row made codex exec --trust and codex review --trust exit 1 and left the row unchanged.
  • Codex 0.169.0 release notes, 13 November 2026. The bug-fix bullet for pull request 60041 is the contract measured above.
  • Pull request 60041, merged 7 November 2026. It describes keeping project configuration and MCP servers disabled in exec runs even with --sandbox workspace-write, adding --trust to codex exec and codex review, persisting the grant with --ephemeral, refusing explicitly untrusted projects, and rejecting the combination with --ignore-user-config.