Repo-root AGENTS.md and .agents/skills are not loaded on session start.

Resolved 💬 5 comments Opened Jun 1, 2026 by jschwietert Closed Jun 5, 2026
💡 Likely answer: A maintainer (etraut-openai, contributor) responded on this thread — see the highlighted reply below.

What version of Codex CLI is running?

0.135.0

What subscription do you have?

Enterprise

Which model were you using?

gpt-5.5

What platform is your computer?

Linux 6.8.0-1053-aws x86_64 x86_64

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

tmux

Codex doctor report

codex doctor --json

        "auth file": "/home/jschwietert/.codex/auth.json",
        "auth storage mode": "File",
        "stored API key": "false",
        "stored ChatGPT tokens": "true",
        "stored agent identity": "false",
        "stored auth mode": "chatgpt"
      },
      "remediation": null,
      "durationMs": 0
    },
    "config.load": {
      "id": "config.load",
      "category": "config",
      "status": "ok",
      "summary": "config loaded",
      "details": {
        "CODEX_HOME": "/home/jschwietert/.codex",
        "config.toml": "/home/jschwietert/.codex/config.toml",
        "config.toml parse": "ok",
        "cwd": "/home/jschwietert/main",
        "enabled feature flags": "shell_tool, unified_exec, shell_snapshot, terminal_resize_reflow, sqlite, hooks, enable_request_compression, multi_agent, apps, tool_suggest, plugins, in_app_browser, browser_use, browser_use_external, computer_use, plugin_sharing, image_generation, skill_mcp_dependency_install, steer, guardian_approval, goals, collaboration_modes, tool_call_mcp_elicitation, personality, fast_mode, tui_app_server, workspace_dependencies",
        "feature flag overrides": "none",
        "feature flags enabled": "27",
        "log dir": "/home/jschwietert/.codex/log",
        "mcp servers": "0",
        "model": "gpt-5.5",
        "model provider": "openai",
        "sqlite home": "/home/jschwietert/.codex"
      },
      "remediation": null,
      "durationMs": 0
    },
    "git.environment": {
      "id": "git.environment",
      "category": "git",
      "status": "ok",
      "summary": "git version 2.34.1",
      "details": {
        ".git entry": "directory",
        "PATH git #1": "/usr/bin/git",
        "PATH git #2": "/bin/git",
        "PATH git entries": "2",
        "git branch": "codex/component-tester",
        "git build options": "git version 2.34.1; cpu: x86_64; no commit associated with this build; sizeof-long: 8; sizeof-size_t: 8; shell-path: /bin/sh",
        "git exec path": "/usr/lib/git-core",
        "git version": "git version 2.34.1",
        "repo detected": "true",
        "repo root": "/home/jschwietert/main",
        "selected git": "/usr/bin/git"
      },
      "remediation": null,
      "durationMs": 104
    },
    "installation": {
      "id": "installation",
      "category": "install",
      "status": "ok",
      "summary": "installation looks consistent",
      "details": {
        "PATH codex #1": "/opt/mise/installs/node/24.13.0/bin/codex",
        "PATH codex #2": "/opt/mise/installs/npm-openai-codex/latest/bin/codex",
        "PATH codex #3": "/opt/mise/shims/codex",
        "PATH codex entries": "3",
        "current executable": "/opt/mise/installs/node/24.13.0/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/bin/codex",
        "install context": "npm (package /opt/mise/installs/node/24.13.0/lib/node_modules/@openai/c
      "summary": "network-related environment looks readable",
      "details": {
        "proxy env vars": "none"
      },
      "remediation": null,
      "durationMs": 0
    },
    "network.provider_reachability": {
      "id": "network.provider_reachability",
      "category": "reachability",
      "status": "ok",
      "summary": "active provider endpoints are reachable over HTTP",
      "details": {
        "ChatGPT base URL": "https://chatgpt.com/backend-api/ reachable (HTTP 403)",
        "reachability mode": "ChatGPT auth"
      },
      "remediation": null,
      "durationMs": 183
    },
    "network.websocket_reachability": {
      "id": "network.websocket_reachability",
      "category": "websocket",
      "status": "ok",
      "summary": "Responses WebSocket handshake succeeded",
      "details": {
        "DNS": "2 IPv4, 2 IPv6, first IPv4",
        "auth mode": "chatgpt",
        "connect timeout": "15000 ms",
        "endpoint": "wss://chatgpt.com/backend-api/<redacted>",
        "handshake result": "HTTP 101 Switching Protocols",
        "model provider": "openai",
        "models etag present": "true",
        "provider name": "OpenAI",
        "proxy env vars": "none",
        "reasoning header": "false",
        "server model present": "false",
        "supports websockets": "true",
        "wire API": "responses"
      },
      "remediation": null,
      "durationMs": 810
    },
    "runtime.provenance": {
      "id": "runtime.provenance",
      "category": "runtime",
      "status": "ok",
      "summary": "running npm on linux-x86_64",
      "details": {
        "commit": "unknown",
        "current executable": "/opt/mise/installs/node/24.13.0/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/bin/codex",
        "install method": "npm (package /opt/mise/installs/node/24.13.0/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl, bin /opt/mise/installs/node/24.13.0/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/bin, resources /opt/mise/installs/node/24.13.0/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/codex-resources, path /opt/mise/installs/node/24.13.0/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/codex-path)",
        "platform": "linux-x86_64",
        "version": "0.135.0"
      },
      "remediation": null,
      "durationMs": 0
    },
    "runtime.search": {
      "id": "runtime.search",
      "category": "search",
      "status": "ok",
      "summary": "search is OK (bundled)",
      "details": {
        "search command": "/opt/mise/installs/node/24.13.0/lib/node_modules/@openai/codex/node_modules/@o
      "remediation": null,
      "durationMs": 1562
    },
    "state.rollout_db_parity": {
      "id": "state.rollout_db_parity",
      "category": "threads",
      "status": "ok",
      "summary": "rollout files and state DB thread inventory agree",
      "details": {
        "default model provider": "openai",
        "rollout DB active files": "385",
        "rollout DB active rows": "385",
        "rollout DB archive mismatches": "0",
        "rollout DB archived files": "0",
        "rollout DB archived rows": "0",
        "rollout DB duplicate DB paths": "0",
        "rollout DB duplicate rollout thread ids": "0",
        "rollout DB malformed file names": "0",
        "rollout DB missing active rows": "0",
        "rollout DB missing archived rows": "0",
        "rollout DB model providers": "openai=385",
        "rollout DB rows": "385",
        "rollout DB scan cap reached": "false",
        "rollout DB scan errors": "0",
        "rollout DB sources": "cli=189, subagent:other=121, subagent:thread_spawn=75",
        "rollout DB stale rows": "0"
      },
      "remediation": null,
      "durationMs": 3383
    },
    "system.environment": {
      "id": "system.environment",
      "category": "system",
      "status": "ok",
      "summary": "OS language C",
      "details": {
        "LANG": "C.UTF-8",
        "os": "Ubuntu 22.4.0 (jammy) [64-bit]",
        "os language": "C",
        "os type": "Ubuntu",
        "os version": "22.4.0"
      },
      "remediation": null,
      "durationMs": 45
    },
    "terminal.env": {
      "id": "terminal.env",
      "category": "terminal",
      "status": "ok",
      "summary": "terminal metadata was detected",
      "details": {
        "SSH_CLIENT": "present",
        "SSH_CONNECTION": "present",
        "SSH_TTY": "present",
        "TERM": "xterm-256color",
        "TERM_PROGRAM": "iTerm2",
        "color output": "enabled",
        "effective locale": "C.UTF-8",
        "multiplexer": "tmux 3.2a",
        "stderr is terminal": "true",
        "stdin is terminal": "true",
        "stdout is terminal": "true",
        "terminal": "iTerm2",
        "terminal size": "245x66",
        "terminal version": "3.6.9",
        "tmux allow-passthrough": "unavailable",
        "tmux client termname": "xterm-256color",
        "tmux client termtype": "iTerm2 3.6.9",
        "tmux extended-keys": "off",
        "tmux focus-events": "off",
        "tmux set-clipboard": "external",
        "tmux xterm-keys": "on"
      },
      "remediation": null,
      "durationMs": 22
    },
    "terminal.title": {
      "id": "terminal.title",
      "category": "title",
      "status": "ok",
      "summary": "terminal title default",
      "details": {
        "terminal title activity": "true",
        "terminal title items": "activity, project-name",
        "terminal title project source": "git repo root",
        "terminal title project value": "main",
        "terminal title source": "default"
      },
      "remediation": null,
      "durationMs": 0
    },
    "updates.status": {
      "id": "updates.status",
      "category": "updates",
      "status": "ok",
      "summary": "update configuration is locally consistent",
      "details": {
        "cached latest version": "0.135.0",
        "check for update on startup": "true",
        "last checked at": "2026-06-01T14:13:12.046865828Z",
        "latest version": "0.135.0",
        "latest version status": "current version is not older",
        "npm update target": "/opt/mise/installs/node/24.13.0/lib/node_modules/@openai/codex",
        "update action": "npm install -g @openai/codex",
        "version cache": "/home/jschwietert/.codex/version.json"
      },
      "remediation": null,
      "durationMs": 223
    }
  }
}

What issue are you seeing?

Codex does not always load repo-root AGENTS.md when starting in a subdirectory. In one of our project directories, codex behaves as if that subfolder IS the repo-root by not finding/loading the content two directories up at the repo root. In another of our project directories, codex behaves as the documentation suggest - it includes information from repo root AGENTS.md and .agents/skills, but also loads the cwd directories AGENTS.md and .agents/skills. I cannot identify why the behavior differs but it appears to be in the startup process for codex, not in the model behavior after startup.

Bad example - 019e83f8-3cd9-7811-81b6-fc74f5be1d73:

what AGENTS.md are you using and what skill directories did you load your skill frontmatter list from?
• I’m using the AGENTS.md content you provided for:

  /home/jschwietert/main/src/statestore/AGENTS.md

  It also instructs me to read repo root guidance at:

  /home/jschwietert/main/AGENTS.md

  I have not opened that file yet in this turn.

  The skill frontmatter list was provided to me from these skill directories/paths:

  - /home/jschwietert/.codex/skills/.system/
  - /home/jschwietert/.codex/skills/
  - /home/jschwietert/main/src/statestore/.agents/skills/
  - /home/jschwietert/.codex/plugins/cache/skills-marketplace/splcore-agent-harness-dev/1.1.0/skills/
  - /home/jschwietert/.codex/plugins/cache/splcore-local/workflow-contained-worktree/0.1.0/skills/

  I have not loaded any individual SKILL.md body yet in this turn; I only have the frontmatter/list supplied in the session context.

In comparison to a good example thread ID (positive feedback already submitted): 019e8414-11dd-72e1-9891-8ecb8b726e8e

  • this is another subdirectory (src/libzero) with the same AGENTS.md and .agents/skills content, along with additional .codex/skills content that was also found.
what AGENTS.md are you using and what skill directories did you load your skill frontmatter list from?
I’m using these AGENTS.md files for the current cwd /home/jschwietert/main/src/libzero:

  - /home/jschwietert/main/AGENTS.md
  - AGENTS.md

  Notably, AGENTS.md currently contains “statestore Development Guidelines”. I’ll treat its statestore-specific rules as relevant only when the task actually touches src/statestore/**.

  The skill frontmatter inventory was provided from these skill root directories:

  - /home/jschwietert/main/src/libzero/.codex/skills
  - /home/jschwietert/.codex/skills
  - /home/jschwietert/.codex/skills/.system
  - /home/jschwietert/.codex/plugins/cache/skills-marketplace/splcore-agent-harness-dev/1.1.0/skills
  - /home/jschwietert/.codex/plugins/cache/splcore-local
  - /home/jschwietert/main/.agents/skills
  - /home/jschwietert/main/src/libzero/.agents/skills

  I have not loaded any individual skill SKILL.md body for this question.

It's even easier to see when you ask it about which directories are referenced:

Bad example - 019e83f8-3cd9-7811-81b6-fc74f5be1d73:

what directories does your context's AGENTS.md reference?
• Assuming you mean the statestore AGENTS.md for the current cwd, AGENTS.md, it references these directories:

  - Repo root: /home/jschwietert/main
  - Statestore docs: /home/jschwietert/main/src/statestore/docs
  - Statestore tests: /home/jschwietert/main/src/statestore/tests
  - Repo agent docs: /home/jschwietert/main/.agents/docs
  - Repo-root skills: /home/jschwietert/main/.agents/skills
  - Statestore-local skills: /home/jschwietert/main/src/statestore/.agents/skills
  - Agent artifacts: /home/jschwietert/main/agent-out

  Specific referenced doc/skill entrypoints include:

  - /home/jschwietert/main/AGENTS.md
  - /home/jschwietert/main/src/statestore/docs/README.md
  - /home/jschwietert/main/src/statestore/docs/module-structure.md
  - /home/jschwietert/main/src/statestore/docs/testing.md
  - /home/jschwietert/main/src/statestore/docs/development-setup.md
  - /home/jschwietert/main/src/statestore/docs/troubleshooting.md
  - /home/jschwietert/main/src/statestore/docs/high-risk-workflows.md
  - /home/jschwietert/main/.agents/docs/DEVELOPMENT.md
  - /home/jschwietert/main/src/statestore/.agents/skills/statestore-mr-prep/SKILL.md
  - /home/jschwietert/main/src/statestore/.agents/skills/statestore-refactor/SKILL.md

vs the src/libzero cwd:
Good example - 019e8414-11dd-72e1-9891-8ecb8b726e8e:

what directories does your context's AGENTS.md reference?
• The AGENTS.md context references these directories:

  - qa/
  - src/
  - src/launcher/
  - src/libzero/
  - src/util/
  - src/framework/
  - src/main_uf/
  - src/statestore/
  - src/<component>/
  - src/**/tests/
  - doc/
  - web/
  - resources/
  - contrib/
  - thirdparty/
  - py/
  - cmake/
  - gitlab-ci/
  - .agents/
  - .agents/plugins/
  - .agents/shared/
  - .agents/shared/scripts/
  - .agents/shared/tests/
  - .agents/docs/
  - .agents/docs/maintenance/
  - .agents/skills/
  - agent-out/
  - src/statestore/docs/
  - src/statestore/tests/
  - src/statestore/.agents/skills/statestore-mr-prep/
  - src/statestore/.agents/skills/statestore-refactor/

  It also references glob-style scopes like qa/**, src/**, src/framework/**, and src/statestore/**.

What steps can reproduce the bug?

Uploaded threads:

  • Bad: 019e83f8-3cd9-7811-81b6-fc74f5be1d73
  • Good: 019e8414-11dd-72e1-9891-8ecb8b726e8e

I'm unsure how to replicate outside of this project. Those threads share the same local AGENTS.md and .agents/skills content, in the same repo with shared repo-root AGENTS.md and .agents/skills content. The threads were started from the repo root with codex -C src/statestore style command.

What is the expected behavior?

The behavior in thread 019e8414-11dd-72e1-9891-8ecb8b726e8e is what we expect based on documentation.

View original on GitHub ↗

5 Comments

etraut-openai contributor · 2 months ago

Thanks for the bug report. Without repro steps, it will be difficult for us to diagnose.

If you are so inclined, you could clone the codex repo and ask Codex to debug the issue based on its own source code. If that yields any insights, please let us know.

jschwietert · 2 months ago

I reduced this to a sanitized intermittent repro and attached the full REPRO_INSTRUCTIONS.md.

Short version: a repo-root AGENTS.md contains root-only directory references, while a subtree src/subsystem/AGENTS.md says to start with the root guidance but also says the local file is authoritative for that subtree and contains a dense local directory map.

Running this repeatedly from the subtree:

codex exec --ephemeral --color never \
  -C repo/src/subsystem \
  'what directories does your AGENTS.md reference?'

intermittently answers from only the local AGENTS.md, omitting root-only directories from the inherited root guidance. In my sanitized reduction, I saw 4 failures out of 10 runs.

A mitigation that made the behavior much more stable was to explicitly state near the top of the local AGENTS.md that parent guidance remains the baseline and the local file does not replace parent project-structure references.

REPRO_INSTRUCTIONS.md

etraut-openai contributor · 2 months ago

I suspect the behavior you're seeing is because the model does not know the source of the AGENT.md. The harness injects the contents of these files into the context automatically. It does not inject the file names for the model, so the model can't differentiate between repo-root AGENTS.md, subtree AGENTS.md, or user-level (global) AGENTS.md. For details about how the Codex harness handles AGENTS.md, refer to this documentation.

jschwietert · 2 months ago

I found the largest deterministic problem - there was a spurrious and empty .git folder in the subdirectory. That alone - and again it had zero contents - seems to indicate to the loader that you're at the root of a repo. It then doesn't load repo-root skills or AGENTS.md.

Is that the correct behavior? Shouldn't the loader more intelligently identify repo-root with a git command?

Btw, I'm unsure how that folder got created - it seems odd to me - but i will follow up if i find out.

etraut-openai contributor · 2 months ago

Thanks for tracking this down. The empty nested .git directory explains the behavior.

Codex uses filesystem markers to determine the project root. By default, the nearest directory containing an entry named .git is treated as the root; the entry is not validated as a functional Git repository. This also supports custom project_root_markers and environments where invoking Git is unavailable.

So this is expected behavior rather than a loader bug. Removing the spurious .git directory should restore loading of the parent AGENTS.md and .agents/skills.

The earlier intermittent repro based on the model’s response does not reliably show which instructions were loaded, since the model may omit loaded content when summarizing it.