Skip to content

Dynamically loading nested AGENTS.md #12115

Open

Description

@kszlim

Tracker summary

Codex should make nested AGENTS.md behavior easier to understand and debug, especially when deeper files are expected to override shallower repo-level guidance.

Customer signal

  • Customer: Wix
  • Submitted by: Andrew Ginns
  • Source: #codex-feedback, 2026-05-05 05:15 PDT

Evidence

Wix reported issues with nested AGENTS.md behavior and referenced GitHub issue #12115. The source question asks whether deeper AGENTS.md files should override shallower ones and whether the current issue is a UX/documentation gap around explaining what happens.

Rollup rule

Track nested AGENTS.md precedence and explanation here. Broader rollout-playbook and rules guidance remains in CEF-65.

Affected accounts

  • Stripe LLC - 1 structured evidence item; highest priority: Must have; latest source: 2026-07-13
  • Reddit - 1 structured evidence item; highest priority: Must have; latest source: 2026-08-31
  • Wix - 1 structured evidence item; highest priority: Blocker; latest source: 2026-08-31
  • Palantir - 1 structured evidence item; highest priority: Must have; latest source: 2026-08-31

Capture notes

Issue metadata

{
  "schema_version": "codex_voc_issue_v2",
  "canonical_problem_summary": "Codex should officially load nested AGENTS.md files on demand as work moves into deeper subtrees from repo-root sessions, with deterministic deeper-over-shallower instruction behavior and visibility into active instruction files.",
  "issue_kind": "Product feedback",
  "feedback_theme_l1": "product_surface_capabilities",
  "feedback_theme_l2": "codex_workflow_gaps",
  "secondary_themes": [],
  "affected_accounts": ["Stripe LLC", "Reddit", "Wix", "Palantir"],
  "triage_flags": ["Duplicate candidate"]
}

Activity

  1. added
    enhancement
    on Feb 18, 2026
  2. added
    CLI
    on Feb 18, 2026
  3. github-actions commented on Feb 18, 2026

    @github-actions
    Contributor

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

    Powered by Codex Action

  4. kszlim commented on Feb 18, 2026

    @kszlim
    Author

    I don't believe the linked issue is a duplicate, it has some overlap, but this is more of a feature request.

  5. miraclebakelaser commented on Feb 18, 2026

    @miraclebakelaser
    Contributor

    +10 to this. This sort of auto context hydration is a low-hanging fruit for improving agent perf. Launching codex from within subdirectories is a suboptimal solution to this because it means arbitrarily walling off work on different parts of the same repo into separate projects/environments.

    It's also part of the AGENTS.md standard:

    1. Large monorepo? Use nested AGENTS.md files for subprojects
      Place another AGENTS.md inside each package. Agents automatically read the nearest file in the directory tree, so the closest one takes precedence and every subproject can ship tailored instructions. For example, at time of writing the main OpenAI repo has 88 AGENTS.md files.

    --

    I think this is a much more natural workflow, though it might come at the expense of some context.

    It's the opposite, it affords you more context bc it reduces the need for a monolithic root AGENTS.md.

  6. added
    context
    and removed
    CLI
    on Feb 18, 2026
  7. foontinz commented on Feb 20, 2026

    @foontinz
    • on this feature
  8. Lewiatan commented on Mar 18, 2026

    @Lewiatan

    +1 on this

  9. amit-mittal commented on Mar 18, 2026

    @amit-mittal

    Until this feature is implemented, we have added below in our AGENTS.md and it seems to be working fairly well.

    ## Enhancing Context
    - Before doing or planning changes under `go/` directory, always load `gocode/AGENTS.md`.
    - Before doing or planning changes under `python/` directory, always load `python/AGENTS.md`.
    - If there are any other `AGENTS.md` in any of the parent directories of the relevant files, load them in the context too.
    
  10. amakarenko-sumy commented on Mar 28, 2026

    @amakarenko-sumy

    +1 on this

  11. MuhammedAlkhudiry commented on Apr 5, 2026

    @MuhammedAlkhudiry

    temporary fix add to global AGENTS.md

    In a monorepo, if the work include one repo or package or more, read its nested `AGENTS.md`.
    
  12. ericchernuka commented on Apr 15, 2026

    @ericchernuka

    Having native support for this that matches the behaviour of Claude would be a great way to align the behaviours across our teams.

  13. petroslamb commented on Apr 29, 2026

    @petroslamb

    What is the design decision against this feature? I only see thumbs up, should be scheduled then.

  14. 18 remaining items

  15. liaoyuanng commented on Aug 5, 2026

    @liaoyuanng

    This is an essential feature for monorepos and cross-platform repositories.

  16. rascio commented on Oct 26, 2026

    @rascio

    Claude cli is much better than you. It can do it.

  17. balabommablock-cpu commented on Oct 27, 2026

    @balabommablock-cpu

    Today, going by codex-rs/core/src/agents_md.rs on main, Codex reads every AGENTS.md from the project root down to the folder you started in, and nothing below it. So if you start at the repo root, packages/web/AGENTS.md is never seen, which is what most of this thread runs into.

    The tracker note above also asks to "explain what happens". So here are the choices that need an answer, with the simplest option for each:

    1. When to load. The first time the agent reads or edits a file in a folder that has its own AGENTS.md. Not at startup, because big monorepos would load everything.
    2. Which file wins. The same rule as today, just extended: root first, then each deeper file, so the deeper one wins for its own folder. The root file still applies everywhere.
    3. Show it. One line in the transcript, like Loaded packages/web/AGENTS.md, and /status lists the files in use. That alone answers most "why did it ignore my rules" questions.
    4. Size. Count it against project_doc_max_bytes. If a file doesn't fit, say it was skipped instead of dropping it silently.
    5. How long it stays. Once loaded, keep it for the rest of the thread, including after compaction. That's easier to predict than loading and unloading as the agent moves around.

    Smallest first version: 1 and 2 for file reads and edits, plus the transcript line. Shell commands run inside a subfolder could come next.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions