AGENTS.md instructions can be read correctly but then applied inconsistently later in the same session
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.mdwhen 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?
- Use a repository with nested
AGENTS.mdfiles (for example, a repo rootAGENTS.mdplus a subproject-specificAGENTS.md). - 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)
- Start a multi-turn coding session inside the subproject.
- Ask Codex to implement a task that touches models, migrations, and tests.
- Continue the same session for follow-up work or ask Codex to review its own work against the repo rules.
- Observe that later in the same session Codex may still miss explicit
AGENTS.mdrequirements it previously knew, for example by creating a reversibleRunPythonmigration, omittingdb_default, omitting type hints, or needing the user to remind it to re-readAGENTS.mdat 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.mdfiles. - The issue seems to be about instruction retention/application across turns, not file discovery.
- This feels related to, but distinct from:
- #25515 (
AGENTS.mdvalidation requirements losing to higher-precedence runtime instructions) - #13386 (
AGENTS.mdtruncation)
Requested fix
- Treat active
AGENTS.mdrules as sticky session constraints, not one-turn context. - Refresh the relevant
AGENTS.mdfiles automatically when cwd/repo scope changes. - Give the model a structured summary of active
AGENTS.mdrequirements every turn or at least every task/context transition. - Add visible diagnostics showing which
AGENTS.mdfiles are currently active. - Prevent the assistant from claiming
AGENTS.mdcompliance unless the active files were actually loaded/checked.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗