mirror of
https://github.com/openai/codex.git
synced 2026-11-22 15:15:18 +00:00
Preserve base instruction provenance across sessions (#37446)
## Why Persisted base instructions need to retain whether they were explicitly customized or generated from a model template. Without that distinction, forks and config-lock replays can treat model-generated instructions as custom and keep the wrong template after a model or personality change. ## What changed - Record custom or model provenance with base instructions in rollouts and config locks. - Preserve custom instructions across model changes, while allowing model-generated instructions to follow the selected model and personality. - Keep legacy rollouts without provenance compatible and propagate provenance through forks and spawned agents. ## Testing - Cover provenance serialization and legacy rollout decoding. - Cover role personality changes, forked model changes, config-lock replay, and multi-agent configuration. GitOrigin-RevId: 801c26559835f558027ce5112700c0cd31fcb21b
This commit is contained in:
1 parent
e58d9ef447
commit
964a227d8c
29 files changed
+324
-35
No files matched your search
@@ -104,6 +104,7 @@ use codex_protocol::config_types::WebSearchConfig;
|
||||
use codex_protocol::config_types::WebSearchMode;
|
||||
use codex_protocol::config_types::WindowsSandboxLevel;
|
||||
use codex_protocol::models::ActivePermissionProfile;
|
||||
use codex_protocol::models::BaseInstructionsProvenance;
|
||||
use codex_protocol::models::PermissionProfile;
|
||||
use codex_protocol::models::SandboxEnforcement;
|
||||
use codex_protocol::openai_models::ModelsResponse;
|
||||
@@ -689,6 +690,9 @@ pub struct Config {
|
||||
/// Base instructions override.
|
||||
pub base_instructions: Option<String>,
|
||||
|
||||
/// Origin of the configured base instructions when supplied by another session or lockfile.
|
||||
pub base_instructions_provenance: Option<BaseInstructionsProvenance>,
|
||||
|
||||
/// Developer instructions override injected as a separate message.
|
||||
pub developer_instructions: Option<String>,
|
||||
|
||||
@@ -1539,6 +1543,9 @@ impl ConfigBuilder {
|
||||
lock_config_layer_stack,
|
||||
)
|
||||
.await?;
|
||||
if let Some(provenance) = lockfile_toml.base_instructions_provenance {
|
||||
config.base_instructions_provenance = Some(provenance);
|
||||
}
|
||||
config.config_lock_toml = Some(Arc::new(expected_lock_config));
|
||||
config.config_lock_allow_codex_version_mismatch = allow_codex_version_mismatch;
|
||||
config.config_lock_save_fields_resolved_from_model_catalog =
|
||||
@@ -1641,7 +1648,12 @@ impl Config {
|
||||
model_context_window: self.model_context_window,
|
||||
model_auto_compact_token_limit: self.model_auto_compact_token_limit,
|
||||
tool_output_token_limit: self.tool_output_token_limit,
|
||||
base_instructions: self.base_instructions.clone(),
|
||||
base_instructions: self.base_instructions.clone().filter(|_| {
|
||||
!matches!(
|
||||
self.base_instructions_provenance,
|
||||
Some(BaseInstructionsProvenance::Model { .. })
|
||||
)
|
||||
}),
|
||||
personality_enabled: self.features.enabled(Feature::Personality),
|
||||
personality: self.personality,
|
||||
model_catalog: self.model_catalog.clone(),
|
||||
@@ -3922,6 +3934,9 @@ impl Config {
|
||||
let base_instructions = base_instructions
|
||||
.or(file_base_instructions)
|
||||
.or(cfg.instructions.clone());
|
||||
let base_instructions_provenance = base_instructions
|
||||
.as_ref()
|
||||
.map(|_| BaseInstructionsProvenance::Custom);
|
||||
let developer_instructions = developer_instructions.or(cfg.developer_instructions);
|
||||
let include_permissions_instructions = cfg.include_permissions_instructions.unwrap_or(true);
|
||||
let include_apps_instructions = cfg.include_apps_instructions.unwrap_or(true);
|
||||
@@ -4128,6 +4143,7 @@ impl Config {
|
||||
enforce_residency: enforce_residency.value,
|
||||
notify: cfg.notify,
|
||||
base_instructions,
|
||||
base_instructions_provenance,
|
||||
personality,
|
||||
developer_instructions,
|
||||
compact_prompt,
|
||||
|
||||
Reference in new issue
Block a user