Codex Desktop managed worktree creation reports AGENTS.override.md failure even though git worktree add succeeds and no ls-files command is spawned

Open 💬 3 comments Opened Jun 23, 2026 by j3h
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What version of the Codex App are you using (From “About Codex” dialog)?

Version 26.616.71553 • Released Jun 22, 2026

What subscription do you have?

Corporate

What platform is your computer?

Darwin 25.5.0 arm64 arm

What issue are you seeing?

Codex Desktop managed worktree creation fails for a large private monorepo.
The UI reports:

git ls-files failed while locating AGENTS.override.md

However, Git tracing shows that git worktree add succeeds, and the expected
post-create git ls-files --others --ignored --exclude-standard -z --
':(glob)**/AGENTS.override.md'
command is never spawned.

No Codex thread is ever started. The worktree does get created successfully, but cannot be used via Codex.

What steps can reproduce the bug?

  1. Open the repo in Codex Desktop.
  2. Start a new thread using a managed worktree.
  3. Worktree creation fails after git worktree add.
  4. UI reports the AGENTS.override.md error.

What is the expected behavior?

After successful git worktree add, Codex should complete post-create setup
and start the thread, or report the real underlying command/lifecycle error.

Additional information

  • Git: Apple Git 2.50.1
  • Repo shape: large private monorepo, about 68k tracked files, about 900 MB checkout

Manual checks:

  • git worktree add --detach ... main succeeds.
  • The exact AGENTS scan succeeds when run manually.
  • A fresh clone of the repo has the same failure.
  • Parallel checkout reduced worktree creation from about 14s to about 7s, but the failure remains.

Git trace evidence:

  • git worktree add --detach <codex-worktree-path> main exits 0.
  • No traced invocation of:

git ls-files --others --ignored --exclude-standard -z -- ':(glob)**/AGENTS.override.md'

  • Desktop logs around the same attempt show a new conversation/worktree lifecycle issue,

including "Received turn/started for unknown conversation" while worktree creation is in progress.

View original on GitHub ↗

3 Comments

github-actions[bot] contributor · 2 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #28381

Powered by Codex Action

j3h · 2 months ago

I captured a success and failure with GIT_TRACE2 enabled.

Success:

  • git worktree add for .../.codex/worktrees/9326/n2 exited 0 after 7.91s
  • Codex then ran:

git ... ls-files --others --ignored --exclude-standard -z -- :(glob)**/AGENTS.override.md

  • that command exited 0 after 2.15s
  • app log then emitted [worktree-create] ready and owner-thread-set
  • the worktree git admin dir has codex-thread.json and config.worktree

Failure:

  • git worktree add for .../.codex/worktrees/1421/n2 exited 0 after 8.52s
  • no AGENTS.override ls-files command was spawned
  • app log never emitted [worktree-create] ready or owner-thread-set
  • the worktree remains registered in Git, but its admin dir lacks

codex-thread.json and config.worktree

So the bug appears to be that the Desktop post-create continuation is getting
lost/cancelled after successful checkout and before the AGENTS.override scan.
The UI reports "git ls-files failed while locating AGENTS.override.md", but in
the failed trace that git command was never invoked.

j3h · 1 month ago

Update: root cause narrowed down and workaround confirmed

I reproduced this again with Codex Desktop 26.623.101652 (build 4674, codex-cli 0.142.5), and now have a controlled A/B that makes worktree creation succeed without changing the Git binary.

Codex Desktop does the following:

  1. It loads my interactive shell environment using zsh -ilc with CODEX_SHELL=1, then merges that environment into process.env. This explained why launching Codex with a custom PATH did not initially change the result.
  2. Its Git availability check finds the first executable named git in PATH.
  3. On macOS, when that path is exactly /usr/bin/git, it runs:

/usr/bin/xcode-select -p

synchronously with a one-second timeout.

  1. The availability result is cached for ten seconds.
  2. After git worktree add succeeds, Codex unconditionally runs the ignored AGENTS.override.md scan. Because this repository takes roughly 7-14 seconds to check out, that scan can require a fresh availability check.
  3. If the availability check fails, Codex returnsGit is unavailable before spawning git ls-files. The caller discards that underlying error and reports:

git ls-files failed while locating AGENTS.override.md

This matches the original trace, in which git worktree add exited successfully but no git ls-files process was spawned.

The confirming A/B was:

Before:

$ command -v git
/usr/bin/git

Managed worktree creation repeatedly failed after checkout.

I then added an earlier PATH entry pointing to the same Git binary:

ln -s /usr/bin/git "$HOME/.local/bin/git"

$HOME/.local/bin was already before /usr/bin in my interactive
shell PATH. Afterward:

$ command -v git
/Users/.../.local/bin/git

$ git --version
git version 2.50.1 (Apple Git-155)

I did not restart Codex. The next managed-worktree creation succeeded, and the Desktop logs recorded both:

[worktree-create] ready
[worktree-create] owner-thread-set

Since the symlink executes the identical /usr/bin/git binary and only changes the path spelling seen by the availability check, this
strongly implicates the /usr/bin/git-specific preflight.

I have not determined why xcode-select -p intermittently fails inside the Git worker; it succeeds consistently when run manually. Desktop logs do, however, show bursts of Git is unavailable errors while Git continues to work normally outside the app.

Possible fixes:

  • Do not repeat Git availability checking between steps of one successful worktree-creation operation.
  • Treat worktree_pending_create and worktree_managed_create as availability-check bypass contexts after git worktree add has already succeeded.
  • Retry the xcode-select probe or increase its one-second timeout.
  • Preserve the underlying Git is unavailable or spawn error instead of replacing it with the AGENTS.override.md message.
  • Roll back the newly created Git worktree when Desktop bootstrap fails, rather than leaving an orphan.

The orphaned-worktree symptom may be related to #16936, although this issue now has a more specific reproduction and workaround.