CLI fails to read AGENTS.md from the global location by default
Resolved 💬 18 comments Opened Jan 5, 2026 by smitchell-kareo Closed Jan 7, 2026
💡 Likely answer: A maintainer (etraut-openai, contributor)
responded on this thread — see the highlighted reply below.
What version of Codex is running?
codex-cli 0.77.0
What subscription do you have?
Enterprise
Which model were you using?
gpt-5.2-codex xhigh
What platform is your computer?
Darwin 24.6.0 arm64 arm
What issue are you seeing?
Codex CLI fails to load the AGENTS.md from the global location (~/.codex/AGENTS.md) despite it being listed as a valid location here: https://developers.openai.com/codex/guides/agents-md
Codex CLI always fails to load it and I'm forced to spend time telling it where to find it in every new session. It always says:
Step 2 (explanation): - I defaulted to searching only the workspace because I assumed the instruction file would be colocated with the repo and did not expand to the documented global locations unless prompted; that assumption was wrong given your setup. - Each new session starts without memory of prior paths, so if I don’t immediately check the known global location, I repeat the same mistake.
Asking it how to prevent this in new session, it admits it can't
Step 2 (root cause): - I defaulted to a repo-local search because I didn’t include the documented global location in my initial search order. That’s on me; your setup is valid. Progress update: - Step 2: completed. Step 3 (durable fix for new sessions): The only solution that does not depend on me “remembering” in each new session is to make the instructions discoverable from the repo itself. These are the reliable options: 1. Create a symlink AGENTS.md in the repo root pointing to /Users/<username>/.codex/AGENTS.md (single source of truth, no duplication). 2. Copy /Users/<username>/.codex/AGENTS.md into the repo root as AGENTS.md (works everywhere, but duplicates content). 3. I can follow a strict search order that checks the global path first every session, but that still relies on me doing it correctly each time and does not enforce discovery at the repo level.
What steps can reproduce the bug?
- Add an
AGENTS.mdfile to~/.codex - Launch a new codex CLI instance some where (eg: ~/foo) that doesn't contain an
AGENTS.mdfile - Require it load
AGENTS.mdto process requests - Observe it failing to discover the file
What is the expected behavior?
It should load ~/.codex/AGENTS.md when there is no local AGENTS.md defined as it's a valid search location according to documentation.
Additional information
_No response_
18 Comments
Thanks for the bug report. Could you repro with a simple prompt? If so, please use the
/feedbackslash command to upload your logs and session and post the thread ID here. Thanks!Done:
019b95e2-fe57-7032-8879-0f54a40c413bI have my
AGENTS.mdlocated in the global fallback location:The prompt:
In another session I asked it to tell me what the lcoation of the
AGENTS.mdfile it was using and asked to confirm if it was using one or not:Thanks.
Thanks for uploading the session details. It appears that Codex is working correctly.
The model won't know the location of the
AGENTS.mdthat it's using. It's injected by the harness, and the path used by the harness is not provided. So I think this is just a misunderstanding based on the fact that you asked the model for information it doesn't have access to.For details about how Codex handles
AGENTS.md, refer to this documentation.You can also verify that the Codex harness is adding the correct
AGENTS.mdby looking at the session details in your editor. You'll find the session information in~/.codex/sesssions/<year>/<month>/<day>/<session-id>.jsonl.How is it working when I'm following the documentation that you linked, specifically:
I have a file at that location.
Also if that's specifically related to me asking what AGENTS.md file it was using, that was just another example. The real test was asking it to perform an action in a new session and it saying it couldn't find the AGENTS.md and failing, despite me having that file in a proper location according to the documentation. From above:
OK, please try these steps:
AGENTS.mdfile with some content that you can later search for. Use a clean project with no project-levelAGENTS.mdfile.~/.codex/sessiondirectory for the session that was just created. Open the.jsonlfile in an editor.Do you see the contents of your global
AGENTS.mdfile in this.jsonlfile?Long Winded Details
Ok that worked and since it worked I dug further and found the root issue which I think should work but clearly doesn't. Codex isn't able to find the
AGENTS.mdduring a session if it's been told to re-read its instructions as an enforcement/corrective measure.Working with codex I kept running into issues where it performed actions that violated rules/guidance/instructions in the AGENTS.md and when I asked how to make sure it followed those instructions it suggested adding an enforcement mechanisms such as:
I had codex add those suggestions to my main
AGENTS.mdand removing the above blocks from myAGENTS.mdallows it work. However adding those blocks to my simpleAGENTS.mdof:doesn't cause it to break but it does illustrate that having instructions telling codex to re-read the instructions file fails to find it in the global location. There must be some other instructions in my larger
AGENTS.mdthat cause it to stop/fail if it wasn't able to perform the re-read. So in my simple example where I added those Memories and Self-Correction blocks it does answer the question but shows that it failed to re-read the instructions file:I can confirm I see the contents of the
AGENTS.mdin the*.jsonlsession file.tl;dr
~/.codex/AGENTS.mdis loaded on startup~/.codex/AGENTS.mdto re-read itAGENTS.mdbefore taking action, due to it ignoring those instructions during a session, fail until it's told where to find theAGENTS.mdfile in a valid (documented) location.Is it possible that this is related to compaction? Are your sessions long enough to consume most of the context window, which would then cause auto-compaction to occur? We've heard reports of compaction causing some of the details in the original AGENTS.md to be lost.
It could be related to compaction but I'm also fairly certain (not 100% since it was before all the enforcement instructions were added) that it was before compaction.
We just kept running into issues where codex made assumptions that went counter to the instructions, so it suggested adding these, and I'm fairly certain some of them were in new/clean sessions. Things like always assuming we were on Java 17+ and Spring Boot 3.x when in a legacy service that was Java 8 & Spring Boot 2.x. We have details in the
AGENTS.mddescribing our mixed environment and the need to determine Java/SB version before performing work and it usually would implement code that wasn't compatible with that service.But again, I can't be 100% on all the issues and if compaction occurred or not since this was months ago (6+?) and I don't recall specifics.
Neither
~/.codex/AGENTS.mdand/or~/.codex/AGENTS.override.mdworks for me. New session and running/statusshows a blank Agents.md line.I created a prompt which I load into each new session, not ideal but an easy work-around:
Looks like there is a clear bug/diff between
codexand their documentation.@o6uoq, how do you know that AGENTS.md isn't being loaded? The
/statuscommand won't show your global AGENTS.md, only the project-level AGENTS.md. You can look in your session history (found at~/.codex/sessions/YY/MM/DD/THREAD.jsonl) and examine the instructions that are sent to the model. Do you see the contents of your AGENTS files in the session history? Another thing to check: Do you have theCODEX_HOMEenv variable defined and pointing to a location other than~/.codex/?@etraut-openai this is really helpful information, thank you. TIL
/statusdoes not show the global agents being loaded. In thecodexsession, I can see my globalAGENTS.mdbeing loaded. However, there is a nested gist in my globalAGENTS.mdwhichcodexdoes not follow unless I explicitly force it via my/load-promptscommand. Also, while I have your attention, what is the nuance/difference between~/.codex/AGENTS.mdand~/.codex/AGENTS.override.md? ..and is there anyway to forcecodexon load in a new session to follow links in a globalAGENTS.md?I have similar problem and project-level AGENTS.md does not work. The agent seems not follow
@hieuminh65, if you suspect a bug, please use the
/feedbackslash command top upload your logs and session details, open a new issue, and include your thread ID. Also, see my above comment for tips on how you can confirm that your AGENTS file is included in your session history.This was written by ChatGPT itself after i asked Codex to verify if it read AGENTS.md / AGENTS.override.md:
Codex CLI does not reliably load global personal instructions from ~/.codex on Windows.
Expected:
Observed:
Repro:
codex --ask-for-approval never --sandbox danger-full-access exec --cd <repo> "Summarize the highest-priority personal instruction file you loaded, if any, in 3 bullets."
Impact:
Reference: https://developers.openai.com/codex/guides/agents-md/
This is still a problem. Codex just flat ignores any overarching guidance document, on Windows at least.
I kind of given up on trying to figure this out and instead just always start codex cli in same folder where my top-level/big-picture AGENTS.md lives, then i link everything from there (or codex learns itself). I never go into another folder in shell now, instead just doing
cd <my proj> and <instructionsin codex, but often even cd is not needed, it can figure it all on its own. Oh i run--yolomode too.That sounds horrible.
Please @codex fix this properly! This is not sane!