[codex] Add AGENTS.local overlays, @-reference expansion, and source file attribution / provenance like Claude Code

Open 💬 7 comments Opened Jun 17, 2026 by kevinhwang
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What variant of Codex are you using?

Desktop App / CLI

What feature would you like to see?

Summary

Add AGENTS.local.md as an additive instruction overlay and expand @ references from project AGENTS files.

AGENTS.override.md can keep its existing replacement semantics. The new local file would be appended after the effective base instructions, so users can add machine- or workspace-specific guidance without shadowing checked-in project instructions.

Context

Codex currently discovers project instructions by walking from the project root to the selected cwd, choosing one effective instruction file per directory, then rendering the concatenated result into the model-visible AGENTS.md instructions block. That supports repo-shipped instructions and hard local replacement via AGENTS.override.md, but it does not provide an additive local overlay.

It also flattens discovered instruction text without preserving per-file provenance, and project instructions cannot import shared fragments from nearby files.

For motivation, Claude Code publicly documents analogous memory-file ergonomics for CLAUDE.md, local memory files, and @ imports: https://code.claude.com/docs/en/memory#claude-md-files. This feature would be to adapt those broad usability ideas to Codex's existing AGENTS conventions rather than changing the current override behavior.

---

Additional information

I have a branch for this here but don't have permission to open a PR.

Here's essentially how it works:

Behavior

Within each searched directory, Codex now loads:

  1. The effective base instruction file: AGENTS.override.md, otherwise AGENTS.md, otherwise configured fallbacks.
  2. AGENTS.local.md, when present.

The same overlay rule applies to global instructions under Codex home: the selected global base is loaded first, then AGENTS.local.md is appended when present.

Project instruction files can now reference nearby files with @path syntax. References resolve relative to the including file, expand depth-first, and are deduplicated with cycle protection. Expanded fragments are rendered as their own source-labeled instruction entries.

Representative example:

repo/
  AGENTS.md
  AGENTS.local.md
  docs/testing.md

If AGENTS.md contains @docs/testing.md, the model-visible project section is shaped like:

Instructions from `/repo/AGENTS.md`

<contents of AGENTS.md>

Referenced instructions from `/repo/docs/testing.md`

<contents of docs/testing.md>

Local additions from `/repo/AGENTS.local.md`

<contents of AGENTS.local.md>

It also labels global/Codex-home instruction sources in the model-visible AGENTS block, preserving provenance for out-of-cwd global AGENTS.md relative references and covering #29535.

Nuances

AGENTS.override.md remains a replacement for the base file in the same directory. AGENTS.local.md is additive, including when an override file is the selected base.

Reference expansion is intentionally conservative. Referenced project files are canonicalized through the executor filesystem and only included when their canonical target remains inside the canonical project root. This avoids symlink or alias escapes. It also means Codex does not currently implement an interactive approval path for imports outside the project root.

Codex preserves logical AGENTS discovery for cwd/project-root walking, including symlinked cwd layers. Canonicalization is applied to referenced files for containment and dedupe, not to collapse the logical discovery walk itself.

References skip Markdown code spans, fenced code blocks, and HTML comments. Missing or non-file references are ignored; unexpected filesystem errors still surface through the existing loading path.

Approach

The implementation separates replacement and additive instruction sources, carries source-kind provenance through rendering, and labels each project fragment by source path. Project reference expansion is handled during AGENTS loading with bounded depth, bounded file count, canonical dedupe, and existing byte-budget enforcement. Coverage was added at the core loader, Codex-home loader, and exec request layers.

View original on GitHub ↗

7 Comments

github-actions[bot] contributor · 2 months ago

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

  • #26957

Powered by Codex Action

kevinhwang · 2 months ago
Potential duplicates detected. Please review them and close your issue if it is a duplicate.

Not strictly a duplicate.

This request is a superset of that one:

  • It includes a request for provenance-labels like Claude Code so the agent knows which file a particular block came from
  • It includes a request for @-reference expansion like Claude Code
DamianPala · 2 months ago

Strong +1 for this guys! This is a very painful missing feature for brownfield repos where AGENTS.md is already maintained by the team and cannot be polluted with personal workflow notes, local paths, rules etc. AGENTS.override.md is not enough because it replaces the shared instructions. What we need is an additive! Basically the Codex equivalent of CLAUDE.local.md.

lextoumbourou · 1 month ago

AGENTS.local.md would be great!

CLAUDE.local.md in Claude Code is very handy for large monorepos, where you want the agent to focus on a few specific parts you're interested in.

clo3olb · 29 days ago

I don't understand why this feature is not yet implemented. This feature would be great for the users working with their team.

mduchev · 23 days ago

Hopefully this gets implemented soon!

natesol · 1 day ago

Huge +1.

This is a real problem on large or shared codebases. We need harness-level @ imports for shared/modular rules, and an additive AGENTS.local.md so personal notes don't overwrite the team defaults.

Claude already works this way. Not supporting it in Codex makes using both agents in the same repo, or migrating from Claude to Codex, a lot more painful than it needs to be.

The harness already has all the parts and foundation these features need, so it should be pretty simple to implement. Why isn't this a feature already?