AGENTS.md instructions can be read correctly but then applied inconsistently later in the same session

Open 💬 4 comments Opened Jun 2, 2026 by cellis-saasoptics

What variant of Codex are you using?

CLI / terminal agent workflow

What version of Codex CLI is running?

codex-cli 0.136.0

What subscription do you have?

Using Codex through a managed terminal session. I do not have the subscription tier exposed in the session UI.

Which model were you using?

GPT-5 family. The session UI did not expose the exact runtime model, but the local Codex cache on this machine was current as of 2026-06-02 and included gpt-5.5.

What platform is your computer?

macOS

What issue are you seeing?

Codex can correctly read project AGENTS.md files early in a session, but later turns may stop applying those rules reliably.

In practice, Codex will sometimes:

  • miss explicit mandatory rules from AGENTS.md
  • act as if it checked AGENTS.md when it had not re-read the relevant file
  • continue making changes that violate repo policy until the user forces a review

This seems different from AGENTS.md discovery, truncation, or precedence issues. In my case, the files were small enough to be read, and Codex could summarize the rules correctly. The problem was inconsistent retention/application across turns.

What steps can reproduce the bug?

  1. Use a repository with nested AGENTS.md files (for example, a repo root AGENTS.md plus a subproject-specific AGENTS.md).
  2. Put concrete mandatory repo rules in the active AGENTS.md, such as:
  • all new functions/methods/class attributes must have type hints
  • migrations must be additive / forward-only
  • new non-null columns must use db_default
  • when a source or test file changes, run the complete corresponding test file(s)
  1. Start a multi-turn coding session inside the subproject.
  2. Ask Codex to implement a task that touches models, migrations, and tests.
  3. Continue the same session for follow-up work or ask Codex to review its own work against the repo rules.
  4. Observe that later in the same session Codex may still miss explicit AGENTS.md requirements it previously knew, for example by creating a reversible RunPython migration, omitting db_default, omitting type hints, or needing the user to remind it to re-read AGENTS.md at all.

What is the expected behavior?

Once the relevant AGENTS.md files are in scope, Codex should apply those mandatory repo rules reliably for the rest of the session, or until directory context changes.

If directory or repo context changes, Codex should automatically refresh the relevant AGENTS.md files before acting.

Codex also should not say or imply that it followed AGENTS.md unless it actually checked the active files.

What is the actual behavior?

In a live session, Codex initially read the repo AGENTS.md files and could restate the rules. But on later turns it still:

  • missed repo-mandated migration rules
  • missed repo-mandated type-hint rules
  • needed user correction to notice AGENTS.md-driven testing/validation expectations
  • repeated the same pattern more than once in the same session

The net effect is that AGENTS.md behaves more like a soft hint than a durable operating constraint.

Additional information

  • This was observed in a macOS terminal-based Codex session.
  • The repo had both root-level and subproject-level AGENTS.md files.
  • The issue seems to be about instruction retention/application across turns, not file discovery.
  • This feels related to, but distinct from:
  • #25515 (AGENTS.md validation requirements losing to higher-precedence runtime instructions)
  • #13386 (AGENTS.md truncation)

Requested fix

  1. Treat active AGENTS.md rules as sticky session constraints, not one-turn context.
  2. Refresh the relevant AGENTS.md files automatically when cwd/repo scope changes.
  3. Give the model a structured summary of active AGENTS.md requirements every turn or at least every task/context transition.
  4. Add visible diagnostics showing which AGENTS.md files are currently active.
  5. Prevent the assistant from claiming AGENTS.md compliance unless the active files were actually loaded/checked.

View original on GitHub ↗

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