Skip to content

codex does not honor AGENTS.md in sub-folder #9836

Closed as not planned
Closed as not planned

Description

@SunRunAway

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 /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

Activity

  1. added
    bug
    on Jan 25, 2026
  2. github-actions commented on Jan 25, 2026

    @github-actions
    Contributor

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

    Powered by Codex Action

  3. added
    context
    on Jan 25, 2026
  4. etraut-openai commented on Jan 25, 2026

    @etraut-openai
    Contributor

    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.

  5. SunRunAway commented on Jan 25, 2026

    @SunRunAway
    Author

    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

  6. etraut-openai commented on Jan 25, 2026

    @etraut-openai
    Contributor

    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.

  7. SunRunAway commented on Jan 25, 2026

    @SunRunAway
    Author

    got it, sorry for the misunderstanding.

  8. minghinmatthewlam commented on Mar 3, 2026

    @minghinmatthewlam

    @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.

  9. etraut-openai commented on Mar 3, 2026

    @etraut-openai
    Contributor

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

  10. ferbeb commented on May 15, 2026

    @ferbeb

    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: #12115

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcontext

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions