mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Retire Friendly and Pragmatic personality selection (#44946)
## What changed - Use literal model instruction templates and the standard fallback prompt, ignoring legacy personality variables. Retain catalog decoding compatibility and report `supports_personality` as `false` for generated model presets. - Stop emitting `<personality_spec>` developer messages and assigning an implicit Pragmatic configuration default. - Filter Friendly/Pragmatic overrides from TUI requests while preserving explicit `personality = "none"`. With `features.personality` enabled, this opt-out still strips the model's personality section. - Refresh inherited model instructions for agent roles only when the personality opt-out changes, preserving custom instructions. ## Testing Update coverage for literal legacy templates, deprecated overrides on turn start and resume, role instruction refresh, and forwarding the explicit opt-out through thread start, resume, and fork requests. GitOrigin-RevId: 1391db4e565e010569f0885f80013d1f86b45825
This commit is contained in:
1 parent
cebdb732ea
commit
132c739171
23 files changed
+213
-1117
No files matched your search
@@ -2,7 +2,6 @@ use codex_protocol::config_types::Personality;
|
||||
use codex_protocol::config_types::ReasoningSummary;
|
||||
use codex_protocol::openai_models::ConfigShellToolType;
|
||||
use codex_protocol::openai_models::ModelInfo;
|
||||
use codex_protocol::openai_models::ModelInstructionsVariables;
|
||||
use codex_protocol::openai_models::ModelMessages;
|
||||
use codex_protocol::openai_models::ModelVisibility;
|
||||
use codex_protocol::openai_models::TruncationMode;
|
||||
@@ -15,11 +14,6 @@ use codex_utils_output_truncation::approx_bytes_for_tokens;
|
||||
use tracing::warn;
|
||||
|
||||
pub const BASE_INSTRUCTIONS: &str = include_str!("../prompt.md");
|
||||
const DEFAULT_PERSONALITY_HEADER: &str = "You are Codex, a coding agent based on GPT-5. You and the user share the same workspace and collaborate to achieve the user's goals.";
|
||||
const LOCAL_FRIENDLY_TEMPLATE: &str =
|
||||
"You optimize for team morale and being a supportive teammate as much as code quality.";
|
||||
const LOCAL_PRAGMATIC_TEMPLATE: &str = "You are a deeply pragmatic, effective software engineer.";
|
||||
const PERSONALITY_PLACEHOLDER: &str = "{{ personality }}";
|
||||
const PERSONALITY_SECTION_HEADER: &str = "# Personality";
|
||||
|
||||
pub fn with_config_overrides(mut model: ModelInfo, config: &ModelsManagerConfig) -> ModelInfo {
|
||||
@@ -66,38 +60,14 @@ pub fn with_config_overrides(mut model: ModelInfo, config: &ModelsManagerConfig)
|
||||
});
|
||||
model_messages.instructions_template = Some(base_instructions.clone());
|
||||
model_messages.instructions_variables = None;
|
||||
} else {
|
||||
if config.personality_enabled
|
||||
&& config.personality == Some(Personality::None)
|
||||
&& let Some(instructions_template) = model
|
||||
.model_messages
|
||||
.as_mut()
|
||||
.and_then(|messages| messages.instructions_template.as_mut())
|
||||
{
|
||||
*instructions_template =
|
||||
strip_personality_section(std::mem::take(instructions_template));
|
||||
}
|
||||
let uses_local_personality_template = model.used_fallback_model_metadata
|
||||
&& matches!(
|
||||
model.slug.as_str(),
|
||||
"gpt-5.2-codex" | "exp-codex-personality"
|
||||
);
|
||||
if !config.personality_enabled
|
||||
&& let Some(model_messages) = model.model_messages.as_mut()
|
||||
{
|
||||
if uses_local_personality_template {
|
||||
model_messages.instructions_template = Some(BASE_INSTRUCTIONS.to_string());
|
||||
} else {
|
||||
let personality_default = model_messages
|
||||
.get_personality_message(/*personality*/ None)
|
||||
.unwrap_or_default();
|
||||
if let Some(instructions_template) = model_messages.instructions_template.as_mut() {
|
||||
*instructions_template = instructions_template
|
||||
.replace(PERSONALITY_PLACEHOLDER, &personality_default);
|
||||
}
|
||||
}
|
||||
model_messages.instructions_variables = None;
|
||||
}
|
||||
} else if config.personality_enabled
|
||||
&& config.personality == Some(Personality::None)
|
||||
&& let Some(instructions_template) = model
|
||||
.model_messages
|
||||
.as_mut()
|
||||
.and_then(|messages| messages.instructions_template.as_mut())
|
||||
{
|
||||
*instructions_template = strip_personality_section(std::mem::take(instructions_template));
|
||||
}
|
||||
|
||||
model
|
||||
@@ -158,7 +128,7 @@ pub fn model_info_from_slug(slug: &str) -> ModelInfo {
|
||||
available_access_programs: None,
|
||||
availability_nux: None,
|
||||
upgrade: None,
|
||||
model_messages: Some(local_model_messages_for_slug(slug)),
|
||||
model_messages: Some(local_model_messages()),
|
||||
include_skills_usage_instructions: false,
|
||||
include_plugin_usage_instructions: false,
|
||||
include_apps_usage_instructions: false,
|
||||
@@ -192,42 +162,20 @@ pub fn model_info_from_slug(slug: &str) -> ModelInfo {
|
||||
}
|
||||
}
|
||||
|
||||
fn local_model_messages_for_slug(slug: &str) -> ModelMessages {
|
||||
match slug {
|
||||
"gpt-5.2-codex" | "exp-codex-personality" => ModelMessages {
|
||||
persistent_instructions: None,
|
||||
tools: None,
|
||||
instructions_template: Some(format!(
|
||||
"{DEFAULT_PERSONALITY_HEADER}\n\n{PERSONALITY_PLACEHOLDER}\n\n{BASE_INSTRUCTIONS}"
|
||||
)),
|
||||
instructions_variables: Some(ModelInstructionsVariables {
|
||||
personality_default: Some(String::new()),
|
||||
personality_friendly: Some(LOCAL_FRIENDLY_TEMPLATE.to_string()),
|
||||
personality_pragmatic: Some(LOCAL_PRAGMATIC_TEMPLATE.to_string()),
|
||||
}),
|
||||
approvals: None,
|
||||
collaboration_modes: None,
|
||||
auto_review: None,
|
||||
permissions: None,
|
||||
multi_agent: None,
|
||||
token_budget: None,
|
||||
confirmation_policies: None,
|
||||
guardian_v2: None,
|
||||
},
|
||||
_ => ModelMessages {
|
||||
persistent_instructions: None,
|
||||
tools: None,
|
||||
instructions_template: Some(BASE_INSTRUCTIONS.to_string()),
|
||||
instructions_variables: None,
|
||||
approvals: None,
|
||||
collaboration_modes: None,
|
||||
auto_review: None,
|
||||
permissions: None,
|
||||
multi_agent: None,
|
||||
token_budget: None,
|
||||
confirmation_policies: None,
|
||||
guardian_v2: None,
|
||||
},
|
||||
fn local_model_messages() -> ModelMessages {
|
||||
ModelMessages {
|
||||
persistent_instructions: None,
|
||||
tools: None,
|
||||
instructions_template: Some(BASE_INSTRUCTIONS.to_string()),
|
||||
instructions_variables: None,
|
||||
approvals: None,
|
||||
collaboration_modes: None,
|
||||
auto_review: None,
|
||||
permissions: None,
|
||||
multi_agent: None,
|
||||
token_budget: None,
|
||||
confirmation_policies: None,
|
||||
guardian_v2: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ use codex_protocol::openai_models::AutoReviewMessages;
|
||||
use codex_protocol::openai_models::CollaborationModeMessages;
|
||||
use codex_protocol::openai_models::ConfirmationPolicies;
|
||||
use codex_protocol::openai_models::GuardianV2ModelConfig;
|
||||
use codex_protocol::openai_models::ModelInstructionsVariables;
|
||||
use codex_protocol::openai_models::ModelTokenBudgetConfig;
|
||||
use codex_protocol::openai_models::MultiAgentMessages;
|
||||
use codex_protocol::openai_models::MultiAgentModeMessages;
|
||||
@@ -135,99 +136,6 @@ fn base_instruction_override_is_literal_and_preserves_catalog_messages() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn disabled_personality_bakes_default_and_preserves_catalog_approval_messages() {
|
||||
let mut model = model_info_from_slug("unknown-model");
|
||||
let approvals = ApprovalMessages {
|
||||
on_request: Some("user approvals".to_string()),
|
||||
on_request_auto_review: None,
|
||||
never: None,
|
||||
unless_trusted: None,
|
||||
};
|
||||
model.model_messages = Some(ModelMessages {
|
||||
persistent_instructions: Some(String::new()),
|
||||
tools: Some(ToolMessages {
|
||||
send_user_message_async: Some(ToolMessage {
|
||||
description: Some(String::new()),
|
||||
}),
|
||||
}),
|
||||
instructions_template: Some("before {{ personality }} after".to_string()),
|
||||
instructions_variables: Some(ModelInstructionsVariables {
|
||||
personality_default: Some("default".to_string()),
|
||||
personality_friendly: Some("friendly".to_string()),
|
||||
personality_pragmatic: Some("pragmatic".to_string()),
|
||||
}),
|
||||
approvals: Some(approvals.clone()),
|
||||
collaboration_modes: None,
|
||||
auto_review: None,
|
||||
permissions: None,
|
||||
multi_agent: None,
|
||||
token_budget: None,
|
||||
confirmation_policies: None,
|
||||
guardian_v2: None,
|
||||
});
|
||||
let config = ModelsManagerConfig {
|
||||
personality_enabled: false,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let updated = with_config_overrides(model, &config);
|
||||
|
||||
assert_eq!(
|
||||
updated.model_messages,
|
||||
Some(ModelMessages {
|
||||
persistent_instructions: Some(String::new()),
|
||||
tools: Some(ToolMessages {
|
||||
send_user_message_async: Some(ToolMessage {
|
||||
description: Some(String::new()),
|
||||
}),
|
||||
}),
|
||||
instructions_template: Some("before default after".to_string()),
|
||||
instructions_variables: None,
|
||||
approvals: Some(approvals),
|
||||
collaboration_modes: None,
|
||||
auto_review: None,
|
||||
permissions: None,
|
||||
multi_agent: None,
|
||||
token_budget: None,
|
||||
confirmation_policies: None,
|
||||
guardian_v2: None,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn disabled_personality_uses_plain_base_instructions_for_local_personality_models() {
|
||||
let config = ModelsManagerConfig {
|
||||
personality_enabled: false,
|
||||
personality: Some(Personality::Friendly),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
for slug in ["gpt-5.2-codex", "exp-codex-personality"] {
|
||||
let updated = with_config_overrides(model_info_from_slug(slug), &config);
|
||||
|
||||
assert_eq!(
|
||||
updated.model_messages,
|
||||
Some(ModelMessages {
|
||||
persistent_instructions: None,
|
||||
tools: None,
|
||||
instructions_template: Some(BASE_INSTRUCTIONS.to_string()),
|
||||
instructions_variables: None,
|
||||
approvals: None,
|
||||
collaboration_modes: None,
|
||||
auto_review: None,
|
||||
permissions: None,
|
||||
multi_agent: None,
|
||||
token_budget: None,
|
||||
confirmation_policies: None,
|
||||
guardian_v2: None,
|
||||
}),
|
||||
"unexpected model messages for {slug}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn personality_none_strips_catalog_instruction_sources_through_the_next_h1() {
|
||||
let cases = [
|
||||
|
||||
Reference in new issue
Block a user