Codex silently fails loading global AGENTS.md file when encountering encoding issues.

Open 💬 3 comments Opened Mar 14, 2026 by nhauber99
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What version of Codex CLI is running?

codex-cli 0.114.0

What subscription do you have?

Business

Which model were you using?

gpt-5.4

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64

What terminal emulator and version are you using (if applicable)?

PowerShell

What issue are you seeing?

Codex silently fails reading the global AGENTS.md file if encountering encoding issues, see https://github.com/openai/codex/issues/7582 for the more general issue.

What steps can reproduce the bug?

Save AGENTS.md in codex home with unsupported encoding / characters.

What is the expected behavior?

A warning message if loading failed. Otherwise it's incredibly frustrating to troubleshoot and even notice if one change in the AGENTS.md file causes it to not be loaded at all.

Additional information

_No response_

View original on GitHub ↗

3 Comments

github-actions[bot] contributor · 5 months ago

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

  • #13386
  • #13918

Powered by Codex Action

SproutSeeds · 5 months ago

I reproduced this locally. The issue looks like a small shared-core config-loading bug, not something Playwright/UI/Windows-specific.

The failure point appears to be the global instructions loader for ~/.codex/AGENTS.md: it uses read_to_string, and when that fails (including invalid/unsupported encoding), it currently just returns None and moves on with no warning.

So the core problem is that the read failure is silently swallowed.

Locally, I patched that path to:

  • keep missing files silent
  • preserve current override/fallback order
  • surface unreadable global instruction files as startup_warnings

That seems like the right hook because config.startup_warnings is already forwarded through CLI/TUI/app-server startup.

I also added focused tests for:

  • invalid global AGENTS.md is ignored with a warning
  • invalid AGENTS.override.md warns and still falls back to AGENTS.md

Those targeted core tests passed locally.

So my current read is:

  • this issue is real
  • the likely fix is small
  • the missing behavior is warning surfacing, not just encoding support
  • it looks narrower than the broader encoding lane in #7582
gimlichael · 5 months ago

This was written by ChatGPT itself after i asked Codex to verify if it read AGENTS.md / AGENTS.override.md:

Codex CLI does not reliably load global personal instructions from ~/.codex on Windows.

Expected:

  • Per docs, Codex should load ~/.codex/AGENTS.override.md if present, otherwise ~/.codex/AGENTS.md.

Observed:

  • CODEX_HOME is default.
  • ~/.codex/config.toml is present and normal.
  • ~/.codex/AGENTS.override.md exists.
  • A direct self-test inside Codex reports that no personal instruction file was loaded, and only repo-local AGENTS.md was seen.

Repro:
codex --ask-for-approval never --sandbox danger-full-access exec --cd <repo> "Summarize the highest-priority personal instruction file you loaded, if any, in 3 bullets."

Impact:

  • Global personal guidance cannot be trusted as enforced.
  • Users must duplicate critical rules in repo-local AGENTS.md.

Reference: https://developers.openai.com/codex/guides/agents-md/