diff --git a/codex-rs/codex-home/src/instructions/mod.rs b/codex-rs/codex-home/src/instructions/mod.rs index 4f4ea76525..16f8a062b5 100644 --- a/codex-rs/codex-home/src/instructions/mod.rs +++ b/codex-rs/codex-home/src/instructions/mod.rs @@ -1,8 +1,8 @@ use std::io; +use codex_extension_api::Instructions; use codex_extension_api::LoadUserInstructionsFuture; use codex_extension_api::LoadedUserInstructions; -use codex_extension_api::UserInstructions; use codex_extension_api::UserInstructionsProvider; use codex_utils_absolute_path::AbsolutePathBuf; @@ -52,7 +52,7 @@ impl CodexHomeUserInstructionsProvider { let trimmed = contents.trim(); if !trimmed.is_empty() { return LoadedUserInstructions { - instructions: Some(UserInstructions { + instructions: Some(Instructions { text: trimmed.to_string(), source: path, }), diff --git a/codex-rs/codex-home/src/instructions/tests.rs b/codex-rs/codex-home/src/instructions/tests.rs index ee2ba9035c..478681b528 100644 --- a/codex-rs/codex-home/src/instructions/tests.rs +++ b/codex-rs/codex-home/src/instructions/tests.rs @@ -1,8 +1,8 @@ use std::fs; use std::path::Path; +use codex_extension_api::Instructions; use codex_extension_api::LoadedUserInstructions; -use codex_extension_api::UserInstructions; use codex_extension_api::UserInstructionsProvider; use codex_utils_absolute_path::AbsolutePathBuf; use pretty_assertions::assert_eq; @@ -25,7 +25,7 @@ fn expected( warnings: Vec, ) -> LoadedUserInstructions { LoadedUserInstructions { - instructions: Some(UserInstructions { + instructions: Some(Instructions { text: text.to_string(), source: AbsolutePathBuf::try_from(home.path().join(filename)) .expect("absolute source path"), diff --git a/codex-rs/core-api/src/lib.rs b/codex-rs/core-api/src/lib.rs index 566c2bc62f..e422218386 100644 --- a/codex-rs/core-api/src/lib.rs +++ b/codex-rs/core-api/src/lib.rs @@ -83,9 +83,9 @@ pub use codex_exec_server::NoiseChannelPublicKey; pub use codex_exec_server::NoiseRendezvousConnectBundle; pub use codex_exec_server::NoiseRendezvousConnectProvider; pub use codex_extension_api::ExtensionRegistryBuilder; +pub use codex_extension_api::Instructions; pub use codex_extension_api::LoadUserInstructionsFuture; pub use codex_extension_api::LoadedUserInstructions; -pub use codex_extension_api::UserInstructions; pub use codex_extension_api::UserInstructionsProvider; pub use codex_extension_api::empty_extension_registry; pub use codex_features::Feature; diff --git a/codex-rs/core/src/agents_md.rs b/codex-rs/core/src/agents_md.rs index 1d9fc4947c..644407dd99 100644 --- a/codex-rs/core/src/agents_md.rs +++ b/codex-rs/core/src/agents_md.rs @@ -25,7 +25,7 @@ use codex_config::project_root_markers_from_config; use codex_exec_server::ExecutorFileSystem; use codex_exec_server::GetMetadataOptions; use codex_exec_server::ReadFileOptions; -use codex_extension_api::UserInstructions; +use codex_extension_api::Instructions; use codex_file_system::FileSystemSandboxContext; use codex_file_system::FindUpErrorPolicy; use codex_file_system::find_nearest_ancestor_with_markers; @@ -54,7 +54,7 @@ const MAX_CONCURRENT_ANCESTOR_PROBES: usize = 256; /// instructions. pub(crate) async fn load_project_instructions( config: &Config, - user_instructions: Option, + user_instructions: Option, environments: &TurnEnvironmentSnapshot, ) -> io::Result> { let mut loaded = LoadedAgentsMd::from_user_instructions(user_instructions); @@ -285,7 +285,7 @@ fn candidate_filenames(config: &Config) -> Vec<&str> { #[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct LoadedAgentsMd { /// Host-provided user instructions. - user_instructions: Option, + user_instructions: Option, /// Ordered instructions and their provenance. entries: Vec, @@ -298,7 +298,7 @@ impl LoadedAgentsMd { return Self::default(); } Self { - user_instructions: Some(UserInstructions { + user_instructions: Some(Instructions { text: contents, source: path, }), @@ -306,7 +306,7 @@ impl LoadedAgentsMd { } } - fn from_user_instructions(user_instructions: Option) -> Self { + fn from_user_instructions(user_instructions: Option) -> Self { Self { user_instructions: user_instructions .filter(|instructions| !instructions.text.trim().is_empty()), diff --git a/codex-rs/core/src/agents_md_manager.rs b/codex-rs/core/src/agents_md_manager.rs index 6982440f13..4ac0005cee 100644 --- a/codex-rs/core/src/agents_md_manager.rs +++ b/codex-rs/core/src/agents_md_manager.rs @@ -2,7 +2,7 @@ use crate::agents_md::LoadedAgentsMd; use crate::agents_md::load_project_instructions; use crate::config::Config; use crate::environment_selection::TurnEnvironmentSnapshot; -use codex_extension_api::UserInstructions; +use codex_extension_api::Instructions; use codex_protocol::config_types::TrustLevel; use codex_protocol::protocol::TurnEnvironmentSelection; use std::io; @@ -11,7 +11,7 @@ use tokio::sync::Mutex; /// Owns the inputs and cached result of AGENTS.md discovery for a session. pub(crate) struct AgentsMdManager { - user_instructions: Option, + user_instructions: Option, cache: Mutex, } @@ -23,7 +23,7 @@ struct AgentsMdCache { } impl AgentsMdManager { - pub(crate) fn new(user_instructions: Option) -> Self { + pub(crate) fn new(user_instructions: Option) -> Self { Self { user_instructions: user_instructions .filter(|instructions| !instructions.text.trim().is_empty()), @@ -69,7 +69,7 @@ impl AgentsMdManager { self.cache.lock().await.loaded.clone() } - pub(crate) fn user_instructions(&self) -> Option { + pub(crate) fn user_instructions(&self) -> Option { self.user_instructions.clone() } } diff --git a/codex-rs/core/src/agents_md_tests.rs b/codex-rs/core/src/agents_md_tests.rs index bdac2e91d7..adeb74241d 100644 --- a/codex-rs/core/src/agents_md_tests.rs +++ b/codex-rs/core/src/agents_md_tests.rs @@ -25,7 +25,7 @@ use codex_exec_server::RemoveOptions; use codex_exec_server::WalkOptions; use codex_exec_server::WalkOutcome; use codex_exec_server::WriteFileOptions; -use codex_extension_api::UserInstructions; +use codex_extension_api::Instructions; use codex_features::Feature; use codex_protocol::config_types::WindowsSandboxLevel; use codex_protocol::models::PermissionProfile; @@ -311,7 +311,7 @@ impl ExecutorFileSystem for FailingFileSystem { struct TestConfig { config: Config, - user_instructions: Option, + user_instructions: Option, } impl Deref for TestConfig { @@ -506,7 +506,7 @@ async fn make_config(root: &TempDir, limit: usize, instructions: Option<&str>) - config.cwd = root.abs(); config.project_doc_max_bytes = limit; - let user_instructions = instructions.map(|text| UserInstructions { + let user_instructions = instructions.map(|text| Instructions { text: text.to_owned(), source: config.codex_home.join(DEFAULT_AGENTS_MD_FILENAME), }); @@ -555,7 +555,7 @@ async fn make_config_with_project_root_markers( config.cwd = root.abs(); config.project_doc_max_bytes = limit; - let user_instructions = instructions.map(|text| UserInstructions { + let user_instructions = instructions.map(|text| Instructions { text: text.to_owned(), source: config.codex_home.join(DEFAULT_AGENTS_MD_FILENAME), }); @@ -1510,7 +1510,7 @@ async fn instruction_sources_include_global_before_agents_md_docs() { let project_agents = cfg.cwd.join("AGENTS.md"); let expected = LoadedAgentsMd { - user_instructions: Some(UserInstructions { + user_instructions: Some(Instructions { text: "global doc".to_string(), source: global_agents.clone(), }), diff --git a/codex-rs/core/src/guardian/review_session.rs b/codex-rs/core/src/guardian/review_session.rs index 8e9bd6bb12..1c0cb706e5 100644 --- a/codex-rs/core/src/guardian/review_session.rs +++ b/codex-rs/core/src/guardian/review_session.rs @@ -9,7 +9,7 @@ use anyhow::anyhow; use codex_analytics::GuardianReviewAnalyticsResult; use codex_analytics::GuardianReviewSessionAnalyticsParams; use codex_analytics::GuardianReviewSessionKind; -use codex_extension_api::UserInstructions; +use codex_extension_api::Instructions; use codex_history::InitialHistory; use codex_history::RolloutItem; use codex_protocol::ThreadId; @@ -203,7 +203,7 @@ struct GuardianReviewSessionReuseKey { permissions: Permissions, developer_instructions: Option, base_instructions: Option, - user_instructions: Option, + user_instructions: Option, compact_prompt: Option, cwd: PathUri, mcp_servers: Constrained>, @@ -217,7 +217,7 @@ struct GuardianReviewSessionReuseKey { impl GuardianReviewSessionReuseKey { fn from_spawn_config( spawn_config: &Config, - user_instructions: Option, + user_instructions: Option, parent_history_version: u64, ) -> Self { Self { diff --git a/codex-rs/core/src/session/mod.rs b/codex-rs/core/src/session/mod.rs index 6f00a1cb63..a60ed4506d 100644 --- a/codex-rs/core/src/session/mod.rs +++ b/codex-rs/core/src/session/mod.rs @@ -1773,7 +1773,7 @@ impl Session { .clone() } - pub(crate) async fn user_instructions(&self) -> Option { + pub(crate) async fn user_instructions(&self) -> Option { self.services.agents_md_manager.user_instructions() } diff --git a/codex-rs/core/src/session/session.rs b/codex-rs/core/src/session/session.rs index c4a4078809..891f26034a 100644 --- a/codex-rs/core/src/session/session.rs +++ b/codex-rs/core/src/session/session.rs @@ -612,7 +612,7 @@ impl Session { mut session_configuration: SessionConfiguration, environment_selections: &[TurnEnvironmentSelection], config: Arc, - user_instructions: Option, + user_instructions: Option, installation_id: String, auth_manager: Arc, models_manager: SharedModelsManager, diff --git a/codex-rs/core/src/thread_manager_tests.rs b/codex-rs/core/src/thread_manager_tests.rs index 730ce25dd3..575475cf6b 100644 --- a/codex-rs/core/src/thread_manager_tests.rs +++ b/codex-rs/core/src/thread_manager_tests.rs @@ -953,7 +953,7 @@ async fn spawn_internal_session_preserves_parent_lineage_without_forking_history } } - struct ParentInstructionsProvider(codex_extension_api::UserInstructions); + struct ParentInstructionsProvider(codex_extension_api::Instructions); impl codex_extension_api::UserInstructionsProvider for ParentInstructionsProvider { fn load_user_instructions(&self) -> codex_extension_api::LoadUserInstructionsFuture<'_> { @@ -999,7 +999,7 @@ async fn spawn_internal_session_preserves_parent_lineage_without_forking_history ) .expect("managed requirements stack"); - let parent_instructions = codex_extension_api::UserInstructions { + let parent_instructions = codex_extension_api::Instructions { text: "parent user instructions must not be inherited".to_string(), source: config.codex_home.join("AGENTS.md"), }; diff --git a/codex-rs/ext/extension-api/src/lib.rs b/codex-rs/ext/extension-api/src/lib.rs index a166fdd31d..9b7577486a 100644 --- a/codex-rs/ext/extension-api/src/lib.rs +++ b/codex-rs/ext/extension-api/src/lib.rs @@ -90,7 +90,7 @@ pub use registry::ExtensionRegistryBuilder; pub use registry::empty_extension_registry; pub use state::ExtensionData; pub use state::ExtensionDataInit; +pub use user_instructions::Instructions; pub use user_instructions::LoadUserInstructionsFuture; pub use user_instructions::LoadedUserInstructions; -pub use user_instructions::UserInstructions; pub use user_instructions::UserInstructionsProvider; diff --git a/codex-rs/ext/extension-api/src/user_instructions.rs b/codex-rs/ext/extension-api/src/user_instructions.rs index d5fd63c197..67b5e07b87 100644 --- a/codex-rs/ext/extension-api/src/user_instructions.rs +++ b/codex-rs/ext/extension-api/src/user_instructions.rs @@ -3,7 +3,7 @@ use std::pin::Pin; use codex_utils_absolute_path::AbsolutePathBuf; -/// User instructions supplied by the host. +/// Instructions supplied by the host. /// /// `source` must be an absolute filesystem path because the app-server /// `instructionSources` API currently exposes instruction sources as @@ -11,8 +11,8 @@ use codex_utils_absolute_path::AbsolutePathBuf; // TODO(anp): Replace the absolute path with a more general instruction-source // abstraction when non-filesystem providers need first-class attribution. #[derive(Clone, Debug, Eq, PartialEq)] -pub struct UserInstructions { - /// Model-visible user instruction text. +pub struct Instructions { + /// Model-visible instruction text. pub text: String, /// Absolute filesystem path reported through `instructionSources`. pub source: AbsolutePathBuf, @@ -22,7 +22,7 @@ pub struct UserInstructions { #[derive(Clone, Debug, Default, Eq, PartialEq)] pub struct LoadedUserInstructions { /// Loaded instructions, or `None` when the provider has no applicable text. - pub instructions: Option, + pub instructions: Option, /// Recoverable loading problems that should be surfaced during startup. pub warnings: Vec, }