Add a setting to configure persistent instructions

Resolved 💬 7 comments Opened Feb 27, 2026 by amit-mittal Closed Apr 3, 2026
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What variant of Codex are you using?

CLI

What feature would you like to see?

Scenario:
If I update the Codex generated code separately in IDE, sometimes it doesn't refresh the context with the change and end up working on the old copy of the code (generated by codex), so in each turn, I have to remind it to reload the files in its context.

Similar to https://block.github.io/goose/docs/guides/using-persistent-instructions/, if we can provide a way to configure persistent instructions. This will ensure that in case I forgot to include "refresh" part in the instructions, the persistent instructions would have included that by default.

Additional information

_No response_

View original on GitHub ↗

7 Comments

github-actions[bot] contributor · 4 months ago

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

  • #12926
  • #11588
  • #11117
  • #11004

Powered by Codex Action

etraut-openai contributor · 4 months ago

The AGENTS.md mechanism is the recommend way to issue persistent instructions, those that apply to all turns.

amit-mittal · 4 months ago

Correct me, but as part of operation to "compact" the context , codex might remove that from context and the subsequent conversations won't have that information.

etraut-openai contributor · 4 months ago

Have you tried using AGENTS.md? Are you having problems with that approach?

amit-mittal · 4 months ago

I haven't put it in AGENTS.md. I can put in the below instructions and reopen the thread if we run into issues again:

## File freshness / avoid clobbering changes
- Treat files as stale unless you re-read them immediately before editing.
- Before modifying any file, re-open it from disk (e.g., view the current contents) and base edits on that latest version.
- If you made a plan earlier, re-read the target file again right before applying the patch to ensure nothing changed since you last looked.
- After editing, run `git diff` to verify only the intended lines changed and no unrelated content was overwritten.

Let me know if you have any other suggestion.

darlingm contributor · 4 months ago
I haven't put it in AGENTS.md. I can put in the below instructions and reopen the thread if we run into issues again: `` ## File freshness / avoid clobbering changes - Treat files as stale unless you re-read them immediately before editing. - Before modifying any file, re-open it from disk (e.g., view the current contents) and base edits on that latest version. - If you made a plan earlier, re-read the target file again right before applying the patch to ensure nothing changed since you last looked. - After editing, run git diff to verify only the intended lines changed and no unrelated content was overwritten. ``

FYI, having it re-open the files every time before modifying them is going to burn context. When a file has changes, that's unavoidable. But when it's the same, it's a lot of potential context waste, especially that in each prompt it's modifying a file it's going to re-add it to context, not removing the last reads. It might be worth trying to find a different way like telling it whenever it reads a file to keep a list of the file's last modified timestamp, and to check that to see if it needs to re-read it. Perhaps you'd have to tell it to store the list in a temp file. That would avoid compaction nuking the list, and might help it actually track it.

There's ways a file's contents can change and not get noticed using this process, but I think this would be very rare failures. Alternatively, you could have it compare hashes instead of timestamps.

Keeping a list like this would certainly use context too, but if it used it efficiently (search the file in a command rather than read the entire tempfile into context again) it would probably be way less than re-reading files.

It would be interesting if Codex could watch the repo for file changes, and track which files it had read, to automatically know when the file contents in context were stale. There would certainly be decisions to be made about how to implement this, as my proposal is of course nowhere near complete.

etraut-openai contributor · 3 months ago

This feature request hasn't received enough upvotes, so closing.