Rename host instruction payload to Instructions (#40709)

## What changed

Rename the `UserInstructions` type to `Instructions` across the extension API,
its core API re-export, and all consumers. This keeps loading behavior and the
`LoadedUserInstructions` provider interface unchanged.

GitOrigin-RevId: 1ac236b34c31718e7aa38ff5eae5e9b179aeedd8
This commit is contained in:
vkg-oai
2026-08-25 21:20:51 +00:00
committed by copyberry
parent 13fe2bcb7a
commit 5ca4175295
12 changed files with 31 additions and 31 deletions
+2 -2
View File
@@ -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,
}),
@@ -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<String>,
) -> LoadedUserInstructions {
LoadedUserInstructions {
instructions: Some(UserInstructions {
instructions: Some(Instructions {
text: text.to_string(),
source: AbsolutePathBuf::try_from(home.path().join(filename))
.expect("absolute source path"),
+1 -1
View File
@@ -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;
+5 -5
View File
@@ -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<UserInstructions>,
user_instructions: Option<Instructions>,
environments: &TurnEnvironmentSnapshot,
) -> io::Result<Option<LoadedAgentsMd>> {
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<UserInstructions>,
user_instructions: Option<Instructions>,
/// Ordered instructions and their provenance.
entries: Vec<InstructionEntry>,
@@ -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<UserInstructions>) -> Self {
fn from_user_instructions(user_instructions: Option<Instructions>) -> Self {
Self {
user_instructions: user_instructions
.filter(|instructions| !instructions.text.trim().is_empty()),
+4 -4
View File
@@ -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<UserInstructions>,
user_instructions: Option<Instructions>,
cache: Mutex<AgentsMdCache>,
}
@@ -23,7 +23,7 @@ struct AgentsMdCache {
}
impl AgentsMdManager {
pub(crate) fn new(user_instructions: Option<UserInstructions>) -> Self {
pub(crate) fn new(user_instructions: Option<Instructions>) -> 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<UserInstructions> {
pub(crate) fn user_instructions(&self) -> Option<Instructions> {
self.user_instructions.clone()
}
}
+5 -5
View File
@@ -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<UserInstructions>,
user_instructions: Option<Instructions>,
}
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(),
}),
+3 -3
View File
@@ -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<String>,
base_instructions: Option<String>,
user_instructions: Option<UserInstructions>,
user_instructions: Option<Instructions>,
compact_prompt: Option<String>,
cwd: PathUri,
mcp_servers: Constrained<HashMap<String, McpServerConfig>>,
@@ -217,7 +217,7 @@ struct GuardianReviewSessionReuseKey {
impl GuardianReviewSessionReuseKey {
fn from_spawn_config(
spawn_config: &Config,
user_instructions: Option<UserInstructions>,
user_instructions: Option<Instructions>,
parent_history_version: u64,
) -> Self {
Self {
+1 -1
View File
@@ -1773,7 +1773,7 @@ impl Session {
.clone()
}
pub(crate) async fn user_instructions(&self) -> Option<codex_extension_api::UserInstructions> {
pub(crate) async fn user_instructions(&self) -> Option<codex_extension_api::Instructions> {
self.services.agents_md_manager.user_instructions()
}
+1 -1
View File
@@ -612,7 +612,7 @@ impl Session {
mut session_configuration: SessionConfiguration,
environment_selections: &[TurnEnvironmentSelection],
config: Arc<Config>,
user_instructions: Option<codex_extension_api::UserInstructions>,
user_instructions: Option<codex_extension_api::Instructions>,
installation_id: String,
auth_manager: Arc<AuthManager>,
models_manager: SharedModelsManager,
+2 -2
View File
@@ -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"),
};
+1 -1
View File
@@ -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;
@@ -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<UserInstructions>,
pub instructions: Option<Instructions>,
/// Recoverable loading problems that should be surfaced during startup.
pub warnings: Vec<String>,
}