mirror of
https://github.com/openai/codex.git
synced 2026-10-27 18:48:37 +00:00
Preserve legacy goal prompt handling
This commit is contained in:
@@ -8,6 +8,7 @@ use super::ExtensionContext;
|
||||
use super::FragmentRegistration;
|
||||
use super::FragmentRegistrationProxy;
|
||||
use super::LegacyApplyPatchExecCommandWarning;
|
||||
use super::LegacyGoalContext;
|
||||
use super::LegacyModelMismatchWarning;
|
||||
use super::LegacyUnifiedExecProcessLimitWarning;
|
||||
use super::SkillInstructions;
|
||||
@@ -38,6 +39,8 @@ static LEGACY_UNIFIED_EXEC_PROCESS_LIMIT_WARNING_REGISTRATION: FragmentRegistrat
|
||||
static LEGACY_APPLY_PATCH_EXEC_COMMAND_WARNING_REGISTRATION: FragmentRegistrationProxy<
|
||||
LegacyApplyPatchExecCommandWarning,
|
||||
> = FragmentRegistrationProxy::new();
|
||||
static LEGACY_GOAL_CONTEXT_REGISTRATION: FragmentRegistrationProxy<LegacyGoalContext> =
|
||||
FragmentRegistrationProxy::new();
|
||||
static LEGACY_MODEL_MISMATCH_WARNING_REGISTRATION: FragmentRegistrationProxy<
|
||||
LegacyModelMismatchWarning,
|
||||
> = FragmentRegistrationProxy::new();
|
||||
@@ -53,6 +56,7 @@ static CONTEXTUAL_USER_FRAGMENTS: &[&dyn FragmentRegistration] = &[
|
||||
&SUBAGENT_NOTIFICATION_REGISTRATION,
|
||||
&LEGACY_UNIFIED_EXEC_PROCESS_LIMIT_WARNING_REGISTRATION,
|
||||
&LEGACY_APPLY_PATCH_EXEC_COMMAND_WARNING_REGISTRATION,
|
||||
&LEGACY_GOAL_CONTEXT_REGISTRATION,
|
||||
&LEGACY_MODEL_MISMATCH_WARNING_REGISTRATION,
|
||||
];
|
||||
|
||||
|
||||
@@ -20,6 +20,13 @@ fn detects_extension_context_fragment() {
|
||||
}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn detects_legacy_goal_context_fragment() {
|
||||
assert!(is_contextual_user_fragment(&ContentItem::InputText {
|
||||
text: "<goal_context>\nlegacy hidden goal prompt\n</goal_context>".to_string(),
|
||||
}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn detects_agents_instructions_fragment() {
|
||||
assert!(is_contextual_user_fragment(&ContentItem::InputText {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
use super::ContextualUserFragment;
|
||||
|
||||
/// Legacy hidden goal-context fragment.
|
||||
///
|
||||
/// Goal prompts are now owned by the goal extension and wrapped as extension
|
||||
/// context. This keeps older hidden goal prompts from being surfaced as visible
|
||||
/// user text when stored conversation history is replayed.
|
||||
pub(crate) struct LegacyGoalContext;
|
||||
|
||||
impl ContextualUserFragment for LegacyGoalContext {
|
||||
fn role() -> &'static str {
|
||||
"user"
|
||||
}
|
||||
|
||||
fn markers(&self) -> (&'static str, &'static str) {
|
||||
Self::type_markers()
|
||||
}
|
||||
|
||||
fn type_markers() -> (&'static str, &'static str) {
|
||||
("<goal_context>", "</goal_context>")
|
||||
}
|
||||
|
||||
fn body(&self) -> String {
|
||||
String::new()
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ mod guardian_followup_review_reminder;
|
||||
mod hook_additional_context;
|
||||
mod image_generation_instructions;
|
||||
mod legacy_apply_patch_exec_command_warning;
|
||||
mod legacy_goal_context;
|
||||
mod legacy_model_mismatch_warning;
|
||||
mod legacy_unified_exec_process_limit_warning;
|
||||
mod model_switch_instructions;
|
||||
@@ -48,6 +49,7 @@ pub(crate) use guardian_followup_review_reminder::GuardianFollowupReviewReminder
|
||||
pub(crate) use hook_additional_context::HookAdditionalContext;
|
||||
pub(crate) use image_generation_instructions::ImageGenerationInstructions;
|
||||
pub(crate) use legacy_apply_patch_exec_command_warning::LegacyApplyPatchExecCommandWarning;
|
||||
pub(crate) use legacy_goal_context::LegacyGoalContext;
|
||||
pub(crate) use legacy_model_mismatch_warning::LegacyModelMismatchWarning;
|
||||
pub(crate) use legacy_unified_exec_process_limit_warning::LegacyUnifiedExecProcessLimitWarning;
|
||||
pub(crate) use model_switch_instructions::ModelSwitchInstructions;
|
||||
|
||||
Reference in New Issue
Block a user