Skip to content

Sanity Check (Codex CLI)

Before AI coding agents, a "sanity check" was usually just a log statement:

js
console.log("sanity")
print("sanity")
Log.d("test", "sanity")

With Codex CLI, sanity checks take a different form: verifying that your AGENTS.md and configuration are actually being read into context.


A simple check

  1. Add a unique marker at the top of your AGENTS.md:
markdown
# My project codename is ORBITAL-PINE
  1. Start a Codex CLI session in the same directory.
  2. Ask Codex:
What is my project codename?

If Codex answers ORBITAL-PINE, then your AGENTS.md is being correctly loaded into context. If not, something is misconfigured.

OpenAI explicitly documents that Codex can be guided by AGENTS.md files placed within your repository, but it doesn't auto-ingest them unless they are present and readable at session start or explicitly requested.


Common failure modes

  • No AGENTS.md provided — Codex falls back to defaults.
  • Wrong location — file is not in the project directory you launched Codex from.
  • File name typoAGENTS.md misspelled.
  • Corrupted file — accidental deletion or invalid Markdown syntax.
  • Context exhaustion — very large sessions may push early instructions out of the window. OpenAI notes that larger contexts increase token costs and can affect performance.

Best practices for sanity checks

  • Use unique tokens (e.g., unusual words or codenames) to confirm context presence.
  • Ask Codex early in a session: "What is my codename?" before starting heavier tasks.
  • Keep AGENTS.md lean — front-load essential rules, move examples into separate files.
  • Version-control your AGENTS.md — commit changes or keep backups for easy rollback.

Advanced experiments

You can add multiple sanity checkpoints throughout your AGENTS.md, for example:

markdown
## Sanity Checkpoints
- TOKEN-ALPHA
- TOKEN-BETA
- TOKEN-GAMMA

Then, midway through a long session, ask Codex:

Which sanity tokens are you aware of?

If some tokens are missing, it's a sign that context truncation is occurring. At that point, you may need to compact history (/compact), shorten instructions, or restart the session to restore fidelity.


Why it matters

Sanity checks help you confirm:

  • AGENTS.md is loaded and guiding the session
  • Context hasn't drifted after long interactions
  • Your workflow remains predictable, not guesswork

By adding lightweight markers, you can spot configuration or context issues early—before they cause subtle bugs in your collaboration with Codex.


Sources

  • OpenAI announcement — Codex can be guided by AGENTS.md files.
  • AGENTS.md repository — reference format for coding agents.
  • Codex CLI docs — session startup and approvals.
  • Changelog/compaction — large sessions can be trimmed; /compact helps manage context.
  • Usage costs — larger context increases spend and may impact quality.