Skip to content

Route AGENTS.md loading through environment filesystems#26205

Merged
anp-oai merged 23 commits into
mainfrom
codex/environment-manager-agents-md-loading
Jun 4, 2026
Merged

Route AGENTS.md loading through environment filesystems#26205
anp-oai merged 23 commits into
mainfrom
codex/environment-manager-agents-md-loading

Conversation

@anp-oai
Copy link
Copy Markdown
Collaborator

@anp-oai anp-oai commented Jun 3, 2026

Why

Workspace-specific AGENTS.md loading needs to use the selected environment filesystem so remote workspaces and child agents read instructions from their actual environment instead of the host filesystem. The app-server should report the same instruction sources the initialized thread actually loaded, rather than independently rescanning configuration and filesystem state.

What changed

  • Introduce LoadedAgentsMd to retain ordered user, project, and internal instructions with their provenance.
  • Load and canonicalize workspace AGENTS.md paths through the primary EnvironmentManager environment, then render the loaded instructions when constructing turn context.
  • Expose cached loaded instruction sources from initialized threads and use them for app-server start, resume, and fork responses.
  • Preserve global CODEX_HOME loading and separator behavior while excluding empty project files that did not supply model-visible instructions.
  • Add integration coverage for CLI injection, selected-environment provenance and rendering, empty environment selection, and cached sources on loaded-thread resume.

Validation

  • just test -p codex-core agents_md
  • just test -p codex-core selected_environment_sources_match_model_visible_instructions
  • just test -p codex-exec agents_md
  • just test -p codex-app-server instruction_sources
  • just test -p codex-app-server --status-level fail

@anp-oai anp-oai force-pushed the codex/environment-manager-agents-md-loading branch from 862c3d0 to 76e5c6b Compare June 3, 2026 17:28
Comment thread codex-rs/core/src/config/mod.rs Outdated
Comment thread codex-rs/core/src/agents_md.rs Outdated
anp-oai added a commit that referenced this pull request Jun 3, 2026
Comment thread codex-rs/core/src/agents_md.rs Outdated
anp-oai added a commit that referenced this pull request Jun 3, 2026
Comment thread codex-rs/core/src/agents_md.rs Outdated
Comment thread codex-rs/core/src/agents_md_tests.rs Outdated
anp-oai added a commit that referenced this pull request Jun 3, 2026
anp-oai added a commit that referenced this pull request Jun 3, 2026
@anp-oai anp-oai marked this pull request as ready for review June 3, 2026 22:12
@anp-oai anp-oai requested a review from a team as a code owner June 3, 2026 22:12
@anp-oai
Copy link
Copy Markdown
Collaborator Author

anp-oai commented Jun 3, 2026

@codex review

Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 04a3f0a677

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/core/src/session/mod.rs
Comment thread codex-rs/core/src/agents_md.rs
Comment thread codex-rs/core/src/agents_md.rs
Comment thread codex-rs/core/src/agents_md.rs
anp-oai added a commit that referenced this pull request Jun 3, 2026
Comment thread codex-rs/exec/tests/suite/agents_md.rs Outdated
Comment thread codex-rs/exec/tests/suite/agents_md.rs
anp-oai added a commit that referenced this pull request Jun 3, 2026
anp-oai added a commit that referenced this pull request Jun 3, 2026
anp-oai added a commit that referenced this pull request Jun 3, 2026
Comment thread codex-rs/exec/tests/suite/agents_md.rs
Comment thread codex-rs/core/src/agents_md.rs
Comment thread codex-rs/core/src/agents_md.rs Outdated
Comment thread codex-rs/core/src/agents_md.rs Outdated
anp-oai added a commit that referenced this pull request Jun 4, 2026
@anp-oai anp-oai force-pushed the codex/environment-manager-agents-md-loading branch from 787d48e to 32cf518 Compare June 4, 2026 18:02
@anp-oai anp-oai enabled auto-merge (squash) June 4, 2026 18:09
Comment thread codex-rs/core/src/agents_md.rs Outdated
if let Ok(canon) = normalize_path(&dir) {
dir = AbsolutePathBuf::try_from(canon)?;
}
let dir = self.config.cwd.clone();
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For posterity, self.config.cwd is already an AbsolutePathBuf and should have been normalized.

@anp-oai anp-oai disabled auto-merge June 4, 2026 18:37
@anp-oai anp-oai merged commit e64b469 into main Jun 4, 2026
31 checks passed
@anp-oai anp-oai deleted the codex/environment-manager-agents-md-loading branch June 4, 2026 19:43
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants