mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +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
@@ -546,6 +546,27 @@ impl Session {
|
||||
session_configuration.collaboration_mode.model(),
|
||||
session_configuration.provider
|
||||
);
|
||||
let base_instructions_provenance = if config.base_instructions.is_some() {
|
||||
Some(
|
||||
config
|
||||
.base_instructions_provenance
|
||||
.clone()
|
||||
.unwrap_or(BaseInstructionsProvenance::Custom),
|
||||
)
|
||||
} else if let Some(inherited_base_instructions) = initial_history.get_base_instructions() {
|
||||
let BaseInstructions { text, provenance } = inherited_base_instructions;
|
||||
provenance.or_else(|| {
|
||||
(text == model_info.get_model_instructions(config.personality)).then(|| {
|
||||
BaseInstructionsProvenance::Model {
|
||||
model: model_info.slug.clone(),
|
||||
}
|
||||
})
|
||||
})
|
||||
} else {
|
||||
Some(BaseInstructionsProvenance::Model {
|
||||
model: model_info.slug.clone(),
|
||||
})
|
||||
};
|
||||
let forked_from_id = session_configuration
|
||||
.forked_from_thread_id
|
||||
.or_else(|| initial_history.forked_from_id());
|
||||
@@ -660,6 +681,7 @@ impl Session {
|
||||
originator: session_configuration.originator.clone(),
|
||||
base_instructions: BaseInstructions {
|
||||
text: session_configuration.base_instructions.clone(),
|
||||
provenance: base_instructions_provenance.clone(),
|
||||
},
|
||||
dynamic_tools: session_configuration.dynamic_tools.clone(),
|
||||
selected_capability_roots: selected_capability_roots.clone(),
|
||||
@@ -1012,16 +1034,22 @@ impl Session {
|
||||
);
|
||||
}
|
||||
session_configuration.thread_name = thread_name.clone();
|
||||
validate_config_lock_if_configured(&session_configuration).await?;
|
||||
export_config_lock_if_configured(&session_configuration, thread_id).await?;
|
||||
validate_config_lock_if_configured(
|
||||
&session_configuration,
|
||||
base_instructions_provenance.as_ref(),
|
||||
)
|
||||
.await?;
|
||||
export_config_lock_if_configured(
|
||||
&session_configuration,
|
||||
thread_id,
|
||||
base_instructions_provenance.as_ref(),
|
||||
)
|
||||
.await?;
|
||||
let mut state = SessionState::new_with_auto_compact_window_ids(
|
||||
session_configuration.clone(),
|
||||
initial_auto_compact_window_ids,
|
||||
);
|
||||
state.base_instructions_model = (config.base_instructions.is_none()
|
||||
&& session_configuration.base_instructions
|
||||
== model_info.get_model_instructions(config.personality))
|
||||
.then(|| model_info.slug.clone());
|
||||
state.base_instructions_provenance = base_instructions_provenance.clone();
|
||||
let managed_network_requirements_configured = config
|
||||
.config_layer_stack
|
||||
.requirements_toml()
|
||||
|
||||
Reference in new issue
Block a user