Automatically reread AGENTS.md within a session when it is modified

Resolved 💬 4 comments Opened Dec 25, 2025 by Igorbunow Closed Feb 23, 2026

What version of Codex is running?

codex-cli 0.77.0

What subscription do you have?

Codex sometimes continues to apply outdated or unintended repository instructions (AGENTS.md, ARCHITECTURE.md-like content) even after files are modified or removed. This can lead to incorrect task behavior, wasted tokens, and confusion, especially in long-running or iterative workflows.

Which model were you using?

gpt-5.1-codex-mini (reasoning medium, summaries auto)

What platform is your computer?

Linux 6.12.48+deb13-amd64 x86_64 unknown

What issue are you seeing?

Codex may continue to apply stale or unintended repository instructions (such as AGENTS.md, ARCHITECTURE.md, or instruction-like files) even after those files are modified or removed from the repository.

In practice, Codex appears to cache previously discovered instructions and reuse them across subsequent tasks in the same session. Additionally, instruction discovery seems overly broad: files that are not intended to be authoritative (e.g. backups, experiments, or similarly named markdown files) may still be interpreted as active instructions.

This leads to incorrect task behavior, unexpected constraints, wasted tokens, and reduced predictability in iterative or long-running workflows.

What steps can reproduce the bug?

What steps can reproduce the bug?

The issue is reproducible with the following steps:

  1. Initialize Codex on a repository that contains an AGENTS.md file (or similar instruction file).
  2. Run a task so that Codex clearly follows the instructions from that file.
  3. Modify or remove the instruction content (for example, edit or delete AGENTS.md or docs/ARCHITECTURE.md).
  4. Run another task in the same Codex session.
  5. Observe that Codex still follows the old or removed instructions.

Additional observations:

  • The behavior is more likely to appear in longer sessions.
  • Files with similar names or instruction-like wording (e.g. AGENTS_backup.md, experimental notes) may also be interpreted as active instructions, even if they are not intended to be authoritative.

What is the expected behavior?

Codex should always apply instructions based on the current repository state.

Specifically:

  • Modified or removed instruction files should take effect immediately (or after a clearly documented reload step).
  • Only clearly defined, canonical instruction files should be considered authoritative.
  • Users should be able to reliably determine which instruction sources are currently active.

Additional information

Practical impact

  • Codex may insist on outdated rules (for example, enforcing specific output formats) even after those rules were removed.
  • Users may unknowingly spend tokens running tasks under incorrect constraints.
  • This is particularly costly and confusing in professional engineering workflows with iterative refinement.

Suggested improvements

  • Restrict instruction loading strictly to files with exact, documented filenames (e.g. AGENTS.md), respecting nearest-scope precedence.
  • Ignore backup, experimental, or similarly named files by default.
  • Provide a documented mechanism (command or flag) to:
  • reload repository instructions, or
  • display which instruction files are currently active.
  • Clearly document instruction caching behavior and its limitations.

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗