Show global AGENTS.md in /status (#17091)

Addresses #3793

Problem: /status only reported project-level AGENTS files, so sessions
with a loaded global $CODEX_HOME/AGENTS.md still showed Agents.md as
<none>.

Solution: Track the global instructions file loaded during config
initialization and prepend that path to the /status Agents.md summary,
with coverage for AGENTS.md, AGENTS.override.md, and global-plus-project
ordering.
This commit is contained in:
Eric Traut
2026-04-08 09:04:32 -07:00
committed by GitHub
parent 4c07dd4d25
commit dc5feb916d
3 changed files with 147 additions and 3 deletions

View File

@@ -245,6 +245,9 @@ pub struct Config {
/// User-provided instructions from AGENTS.md.
pub user_instructions: Option<String>,
/// Path to the global AGENTS file loaded into `user_instructions`.
pub user_instructions_path: Option<PathBuf>,
/// Base instructions override.
pub base_instructions: Option<String>,
@@ -1408,7 +1411,10 @@ impl Config {
network: network_requirements,
} = config_layer_stack.requirements().clone();
let user_instructions = Self::load_instructions(Some(&codex_home));
let (user_instructions, user_instructions_path) =
Self::load_instructions(Some(&codex_home))
.map(|loaded| (Some(loaded.contents), Some(loaded.path)))
.unwrap_or((None, None));
let mut startup_warnings = Vec::new();
// Destructure ConfigOverrides fully to ensure all overrides are applied.
@@ -2001,6 +2007,7 @@ impl Config {
enforce_residency: enforce_residency.value,
notify: cfg.notify,
user_instructions,
user_instructions_path,
base_instructions,
personality,
developer_instructions,
@@ -2168,7 +2175,7 @@ impl Config {
Ok(config)
}
fn load_instructions(codex_dir: Option<&Path>) -> Option<String> {
fn load_instructions(codex_dir: Option<&Path>) -> Option<LoadedUserInstructions> {
let base = codex_dir?;
for candidate in [LOCAL_PROJECT_DOC_FILENAME, DEFAULT_PROJECT_DOC_FILENAME] {
let mut path = base.to_path_buf();
@@ -2176,7 +2183,10 @@ impl Config {
if let Ok(contents) = std::fs::read_to_string(&path) {
let trimmed = contents.trim();
if !trimmed.is_empty() {
return Some(trimmed.to_string());
return Some(LoadedUserInstructions {
contents: trimmed.to_string(),
path,
});
}
}
}
@@ -2250,6 +2260,11 @@ impl Config {
}
}
struct LoadedUserInstructions {
contents: String,
path: PathBuf,
}
pub(crate) fn uses_deprecated_instructions_file(config_layer_stack: &ConfigLayerStack) -> bool {
config_layer_stack
.layers_high_to_low()