Agent unable to read new file in worktree mode.

Resolved 💬 4 comments Opened Feb 20, 2026 by Reekin Closed Feb 20, 2026
💡 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)?

26.217.1959 (669)

What subscription do you have?

Pro

What platform is your computer?

Darwin 25.2.0 arm64 arm

What issue are you seeing?

I created a PRD.md file in the project root directory and then switched to worktree mode in codex app, asking the agent to implement it.
The agent searched for a long time but couldn't find the file, and finally gave up.
The session jsonl (renamed to json) is attached.
rollout-2026-02-21T03-38-57-019c7c8f-fcef-70b2-95de-5ffe2512fc5f.json

What steps can reproduce the bug?

  1. clone codex repo
  2. create an md in the root dir
  3. switch to worktree mode, @ the file and let it implement it

What is the expected behavior?

The agent can find and read the file

Additional information

_No response_

View original on GitHub ↗

4 Comments

github-actions[bot] contributor · 6 months ago

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

  • #12232
  • #11718
  • #10543

Powered by Codex Action

etraut-openai contributor · 6 months ago

Yes, this is expected. When you create a new thread in worktree mode, it works within the context of that worktree's directory. If you had previously created a file in the directory associated with your main checkout, that won't be visible to the agent working in the worktree directory. You could either point the agent at that directory (to tell it about your PRD) or copy the PRD to the worktree directory. For more details, refer to this documentation.

A more typical workflow is to start the thread (issue an initial request) to create the worktree. Then work with the agent to create a plan (e.g. using plan mode) or write a PRD in the context of that new thread.

Reekin · 6 months ago
Yes, this is expected. When you create a new thread in worktree mode, it works within the context of that worktree's directory. If you had previously created a file in the directory associated with your main checkout, that won't be visible to the agent working in the worktree directory. You could either point the agent at that directory (to tell it about your PRD) or copy the PRD to the worktree directory. For more details, refer to this documentation. A more typical workflow is to start the thread (issue an initial request) to create the worktree. Then work with the agent to create a plan (e.g. using plan mode) or write a PRD in the context of that new thread.

But it shows in the @ suggest list, I think this behavior is misleading. Files that the agent can't actually locate shouldn't be @-mentionable.
Upon entering a worktree, the app should either limit '@' mentions to files within that worktree, or still allow mentions of files from the main directory by providing the agent with their absolute paths.

etraut-openai contributor · 6 months ago

That's a valid point. If you're seeing @ mentions reference files within your original directory (as opposed to the directory created after the first prompt is entered and the worktree is created), then please feel free to file a bug report on that issue.