mirror of
https://github.com/openai/codex.git
synced 2026-11-25 23:30:49 +00:00
Remove legacy personality template metadata (#51223)
## What changed - Remove `instructions_variables`, its protocol type, and unused personality templates. Continue accepting older catalogs by ignoring their legacy variables. - Report `supports_personality` as `false` in app-server model listings and TUI model presets. - Preserve pinned model metadata and base instructions when only personality settings change. Reuse Guardian review sessions across friendly and pragmatic settings, while keeping the `none` opt-out distinct. ## Testing Update coverage for legacy catalog deserialization, personality override notifications, opt-out behavior during model switches, and preservation of instructions and history on resume. GitOrigin-RevId: bee8a263ef84046301888d02347f43929ececce9
This commit is contained in:
@@ -202,7 +202,7 @@ pub struct GuardianReviewSessionReuseKey {
|
||||
model_auto_compact_token_limit_scope: AutoCompactTokenLimitScope,
|
||||
model_reasoning_effort: Option<ReasoningEffortConfig>,
|
||||
model_reasoning_summary: Option<ReasoningSummaryConfig>,
|
||||
personality: Option<Personality>,
|
||||
omit_personality: bool,
|
||||
permissions: Permissions,
|
||||
developer_instructions: Option<String>,
|
||||
base_instructions: Option<String>,
|
||||
@@ -246,7 +246,7 @@ impl GuardianReviewSessionReuseKey {
|
||||
model_auto_compact_token_limit_scope: spawn_config.model_auto_compact_token_limit_scope,
|
||||
model_reasoning_effort: spawn_config.model_reasoning_effort.clone(),
|
||||
model_reasoning_summary: spawn_config.model_reasoning_summary,
|
||||
personality: spawn_config.personality,
|
||||
omit_personality: spawn_config.personality == Some(Personality::None),
|
||||
permissions: spawn_config.permissions.clone(),
|
||||
developer_instructions: spawn_config.developer_instructions.clone(),
|
||||
base_instructions: spawn_config.base_instructions.clone(),
|
||||
|
||||
@@ -1886,7 +1886,7 @@ enum GuardianTestCatalog {
|
||||
#[test_case::test_case(None; "captured_policy")]
|
||||
#[test_case::test_case(Some("configured policy wins"); "configured_policy")]
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn guardian_reuse_respects_effective_policy_and_personality(
|
||||
async fn guardian_reuse_respects_effective_policy_and_personality_opt_out(
|
||||
configured_policy: Option<&str>,
|
||||
) -> anyhow::Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
@@ -1894,7 +1894,7 @@ async fn guardian_reuse_respects_effective_policy_and_personality(
|
||||
let server = start_mock_server().await;
|
||||
let responses = mount_sse_sequence(
|
||||
&server,
|
||||
(0..3)
|
||||
(0..4)
|
||||
.map(|index| {
|
||||
sse(vec![
|
||||
ev_response_created(&format!("review-{index}")),
|
||||
@@ -1940,9 +1940,16 @@ async fn guardian_reuse_respects_effective_policy_and_personality(
|
||||
.policy = Some("changed action policy".to_string());
|
||||
let mut different_personality = changed_policy.clone();
|
||||
different_personality.personality = Some(codex_protocol::config_types::Personality::Pragmatic);
|
||||
for (index, context) in [captured, changed_policy, different_personality]
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
let mut omit_personality = different_personality.clone();
|
||||
omit_personality.personality = Some(codex_protocol::config_types::Personality::None);
|
||||
for (index, context) in [
|
||||
captured,
|
||||
changed_policy,
|
||||
different_personality,
|
||||
omit_personality,
|
||||
]
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
{
|
||||
let (outcome, _) = run_guardian_review_session_for_test(
|
||||
Arc::clone(&session),
|
||||
@@ -1956,7 +1963,7 @@ async fn guardian_reuse_respects_effective_policy_and_personality(
|
||||
assert!(matches!(outcome, GuardianReviewOutcome::Completed(_)));
|
||||
}
|
||||
let requests = responses.requests();
|
||||
assert_eq!(requests.len(), 3);
|
||||
assert_eq!(requests.len(), 4);
|
||||
let contract = guardian_output_contract_prompt();
|
||||
for (request, policy) in requests
|
||||
.iter()
|
||||
@@ -1973,7 +1980,8 @@ async fn guardian_reuse_respects_effective_policy_and_personality(
|
||||
.map(|request| request.body_json()["client_metadata"]["thread_id"].clone())
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(thread_ids[0] == thread_ids[1], configured_policy.is_some());
|
||||
assert_ne!(thread_ids[1], thread_ids[2]);
|
||||
assert_eq!(thread_ids[1], thread_ids[2]);
|
||||
assert_ne!(thread_ids[2], thread_ids[3]);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ impl ResolvedStepSettings {
|
||||
}
|
||||
|
||||
/// Applies sparse edits to the retained selection, preserving pinned metadata
|
||||
/// unless model or personality selection changes, then resolves request values.
|
||||
/// unless the model changes, then resolves request values.
|
||||
pub(super) async fn apply_update(
|
||||
&self,
|
||||
update: &StepSettingsUpdate,
|
||||
@@ -132,14 +132,12 @@ impl ResolvedStepSettings {
|
||||
fast_mode_enabled: bool,
|
||||
) -> ConstraintResult<Self> {
|
||||
let selected = self.selected.apply(update, constraints)?;
|
||||
let model_info = if selected.collaboration_mode.model()
|
||||
== self.selected.collaboration_mode.model()
|
||||
&& selected.personality == self.selected.personality
|
||||
{
|
||||
Arc::clone(&self.model_info)
|
||||
} else {
|
||||
Arc::new(selected.resolve_model_info(models_manager, overrides).await)
|
||||
};
|
||||
let model_info =
|
||||
if selected.collaboration_mode.model() == self.selected.collaboration_mode.model() {
|
||||
Arc::clone(&self.model_info)
|
||||
} else {
|
||||
Arc::new(selected.resolve_model_info(models_manager, overrides).await)
|
||||
};
|
||||
let mut next = Self::new(Arc::new(selected), model_info, fast_mode_enabled);
|
||||
next.mcp_approvals_reviewer_override = update
|
||||
.approvals_reviewer
|
||||
|
||||
@@ -431,7 +431,6 @@ async fn model_resolution_preserves_startup_overrides_and_instruction_provenance
|
||||
.expect("test model should have instruction metadata");
|
||||
messages.instructions_template =
|
||||
Some("Catalog B.\n# Personality\nfixed\n# Rules\nKeep the rules.".to_string());
|
||||
messages.instructions_variables = None;
|
||||
messages.auto_review = Some(auto_review);
|
||||
messages.guardian_v2 = Some(guardian_v2);
|
||||
let catalog = ModelsResponse {
|
||||
|
||||
@@ -11288,7 +11288,6 @@ async fn build_initial_context_uses_retained_step_after_model_change() {
|
||||
model_info.max_context_window = None;
|
||||
let messages = model_info.model_messages.as_mut().unwrap();
|
||||
messages.instructions_template = Some("A instructions".to_string());
|
||||
messages.instructions_variables = None;
|
||||
});
|
||||
session
|
||||
.set_previous_turn_settings(Some(PreviousTurnSettings {
|
||||
|
||||
Reference in New Issue
Block a user