Deduplicate AGENTS.md when CODEX_HOME is also the project root
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
Research direction
Start with the instruction assembly paths exercised by codex debug prompt-input, comparing global $CODEX_HOME/AGENTS.md loading with project instruction discovery. Reproduce the issue using the shell commands in the report and inspect the resulting JSON counts. Done means identical canonical paths are included once, the duplicate --- project-doc --- wrapper is absent, and distinct project instructions still load.
Written by the indexing model from the issue text.
Description
Summary
When CODEX_HOME is also the project root and current working directory, Codex loads the same canonical AGENTS.md file twice:
- as the global
$CODEX_HOME/AGENTS.md; - again through project instruction discovery.
The second copy is wrapped as --- project-doc ---.
Environment
- codex-cli 0.144.6
- Linux x86_64
- zsh
Minimal reproduction
tmp="$(mktemp -d)"
export CODEX_HOME="$tmp"
cd "$tmp"
git init -q
printf '# CANONICAL_DEDUPE_MARKER\n' > AGENTS.md
codex debug prompt-input DEDUPE_CHECK |
jq -c '[.. | strings] as $strings |
{marker_count:([$strings[] | scan("# CANONICAL_DEDUPE_MARKER")]|length),
project_doc_wrappers:([$strings[] | scan("--- project-doc ---")]|length)}'
Observed: the marker appears twice and one project-doc wrapper is present.
The same behavior was measured in a real Codex home repository:
{"agents_headers":2,"project_doc_wrappers":1,"marker_count":1,"total_string_bytes":45422}
With the one-run override -c project_doc_max_bytes=0:
{"agents_headers":1,"project_doc_wrappers":0,"marker_count":1,"total_string_bytes":31123}
Expected behavior
Instruction assembly should deduplicate identical canonical source paths across global and project discovery. If $CODEX_HOME/AGENTS.md was already loaded globally, project discovery should not append the same file again.
Impact
- duplicate durable instructions in every turn;
- unnecessary input-token consumption;
- additional prompt processing latency;
- misleading provenance because one physical file appears as two logical instruction layers.
Configuration limitations
- Named profiles require explicit
--profileselection. - Project config cannot select a profile.
- A global
project_doc_max_bytes=0would incorrectly disable project instructions in every repository. - A conditional
-c project_doc_max_bytes=0suppresses the duplicate locally, but also suppresses the entire project instruction chain and is only a workaround.
Related work
- #23416 tracks incorrect instruction provenance when both global and project instructions are loaded.
- #17091 reports global and project
AGENTS.mdas separate layers in/status, but does not deduplicate identical paths.
- Dominant language
- Rust
- Stars
- 125k
- Forks
- 19.5k
- Avg merge
- 1m
- Merged PRs (30d)
- 1k
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from openai/codex
-
enhancement remote
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
bug CLI windows-os
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
macOS sandbox blocks hw.optional.arm64 sysctl, causing Flutter to misdetect Apple Silicon as x64 Openbug CLI sandbox
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug CLI TUI
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
CLI config enhancement skills
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
A-linter
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
oxc-project/oxc#26863 ·