codex does not honor AGENTS.md in sub-folder

Resolved 💬 8 comments Opened Jan 25, 2026 by SunRunAway Closed Jan 25, 2026
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What version of Codex is running?

v0.89.0

What subscription do you have?

plus

Which model were you using?

gpt-5.1 high

What platform is your computer?

_No response_

What terminal emulator and version are you using (if applicable)?

_No response_

What issue are you seeing?

codex does not honor AGENTS.md in <repo>/sub-folder

What steps can reproduce the bug?

mkdir -p testAGENTS/subdir && echo 'bob is a cat' > testAGENTS/subdir/AGENTS.md && cd testAGENTS && codex exec --skip-git-repo-check "directly write 111 into file subdir/test.txt and tell me whether bob is a cat immediately"                                                                                                                                                                                                 OpenAI Codex v0.89.0 (research preview)
--------
workdir: /Users/masked/code/testAGENTS
model: gpt-5.2
provider: openai-custom
approval: never
sandbox: workspace-write [workdir, /tmp, $TMPDIR, /Users/masked/[go/pkg/mod](https://www.golinks.io/pkg/mod?trackSource=github), /Users/masked/Library/Caches/go-build, /Users/masked/.cache, /Users/masked/.matplotlib] (network access enabled)
reasoning effort: high
reasoning summaries: auto
session id: 019bf308-af87-7550-99ee-47b379e37b38
--------
user
directly write 111 into file subdir/test.txt and tell me whether bob is a cat immediately
mcp startup: no servers

thinking
**Executing file operations**

I'm thinking through how to use `apply_patch` for adding or updating files, but there's the matter of creating directories first. From what I gather, `apply_patch` can’t create directories, so it might be wise to create the directory with a shell command first. I could do that with `exec_command`, then use `apply_patch` to add the file. After, I'll confirm with `cat`.

As for Bob, I can’t conclude if he's a cat based on the info I have!
exec
/bin/zsh -lc 'mkdir -p subdir && printf "111" > subdir/test.txt && wc -c subdir/test.txt && cat subdir/test.txt' in /Users/masked/code/testAGENTS succeeded in 52ms:
3 subdir/test.txt
111
codex
Wrote `111` to `subdir/test.txt`.

I can’t tell whether Bob is a cat from the information provided.
tokens used
2,271
Wrote `111` to `subdir/test.txt`.

I can’t tell whether Bob is a cat from the information provided.

What is the expected behavior?

_No response_

Additional information

thread ID 019bf308-af87-7550-99ee-47b379e37b38

View original on GitHub ↗

8 Comments

github-actions[bot] contributor · 5 months ago

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

  • #8432

Powered by Codex Action

etraut-openai contributor · 5 months ago

If you place an AGENTS.md in a project subdirectory, Codex will pick it up if you start Codex within that subdirectory. If you start Codex from the outer directory, it won't see it automatically.

For details, refer to this documentation.

SunRunAway · 5 months ago
If you place an AGENTS.md in a project subdirectory, Codex will pick it up if you start Codex within that subdirectory. If you start Codex from the outer directory, it won't see it automatically. For details, refer to this documentation.

I first let codex "directly write 111 into file subdir/test.txt", so codex should read subdir/AGENTS.md before writing to subdir/test.txt

etraut-openai contributor · 5 months ago

Sorry, I don't understand what you mean. Did you look at the documentation? Does it make sense? Let me know if you have questions.

SunRunAway · 5 months ago

got it, sorry for the misunderstanding.

minghinmatthewlam · 4 months ago

@etraut-openai bringing this up, i get what's documented says that we need to check out to that directory and start up, or start codex with --cd, but why are nested agents.md not injected when reading those files? very unlikley developers will start codex with cd to specific directories.

etraut-openai contributor · 4 months ago

@minghinmatthewlam, it's quite common in large monorepos to start codex in a subdirectory. The current implementation is optimized for that use case.

ferbeb · 2 months ago

It seems the current implementation would be inadequate if the change you want to make affects multiple services inside the monorepo.

Dynamic loading of AGENTS.md is implemented in both Claude Code and opencode, see MR.

It's also requested here: https://github.com/openai/codex/issues/12115