`project_root_markers` is not honored for AGENTS.md discovery
What version of Codex CLI is running?
codex-cli 0.104.0
What subscription do you have?
Plus
Which model were you using?
gpt-5.3-codex
What platform is your computer?
Linux 6.18.7-arch1-1 x86_64 unknown
What terminal emulator and version are you using (if applicable)?
_No response_
What issue are you seeing?
<img width="1263" height="473" alt="Image" src="https://github.com/user-attachments/assets/ffd7587d-903d-4b4d-bf61-41dfd20508b2" />
The docs say Codex discovers project configuration — including both .codex/ layers and AGENTS.md — by walking up from the working directory until it reaches a project root, and that this root can be customized via project_root_markers (or disabled with []).
However, the CLI behavior does not match this documentation for AGENTS.md: even when project_root_markers is explicitly set to a parent marker (e.g., .codex-root), if the cwd contains a nested .git, Codex still resolves AGENTS.md as if the nested .git is a hard boundary and only loads the cwd AGENTS.md.
Observed situation:
/status reports:
Agents.md: AGENTS.md
when it should include the parent ../AGENTS.md as well.
What steps can reproduce the bug?
The following commands create a minimal repro directory structure like:
codex-bug-repro
├── AGENTS.md
├── .codex-root
└── dir1
├── AGENTS.md
└── .git
mkdir -p codex-bug-repro/dir1/.git
touch codex-bug-repro/.codex-root
printf "PARENT AGENTS\n" > codex-bug-repro/AGENTS.md
printf "CHILD AGENTS\n" > codex-bug-repro/dir1/AGENTS.md
cd codex-bug-repro/dir1
codex -c 'project_root_markers=[".codex-root"]' # then run: /status
````
**result:** only `./AGENTS.md` is loaded, and `../AGENTS.md` is ignored.
### What is the expected behavior?
With `project_root_markers=[".codex-root"]` and the parent directory containing `.codex-root`, Codex should:
1. Treat the parent directory as the project root **even if** the cwd contains a nested `.git`.
2. Aggregate and load `AGENTS.md` along the path from project root → cwd (e.g., load both `../AGENTS.md` and `./AGENTS.md`).
3. Reflect this in `/status`, indicating that the parent `AGENTS.md` is included.
In short: `project_root_markers` should apply consistently to `AGENTS.md` discovery, matching the project discovery semantics used for `.codex/` project configuration.
### Additional information
### Root Cause
`codex-rs/core/src/project_doc.rs` resolves `AGENTS.md` by walking up to a **hard-coded `.git` root** and stopping there, so `project_root_markers` is ignored for agent-doc discovery in nested-repo setups.
### Proposed fix
Reuse the `project_root_markers` root-detection logic already used in `codex-rs/core/src/skills/loader.rs`:
- derive markers from merged **pre-project** config layers
- compute project root via markers
- aggregate `AGENTS.md` from `project_root → cwd`, plus a regression test for nested `.git`
**Happy to submit a PR if invited.**
### Related
- Docs: [Advanced Configuration](https://developers.openai.com/codex/config-advanced/#project-root-detection)
- PR: #8359
- PR: #10317This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗