mirror of
https://github.com/openai/codex.git
synced 2026-11-23 23:10:47 +00:00
Add opt-in elastic budgeting for synchronous Guardian reviews (#59444)
## What changed - Add `features.guardianv2.sync_elastic_budgeting` and `sync_elastic_sections` to configure section minimums, per-entry token caps, and optional section maximums. Require and validate section limits when enabled. - Use the selected budgeting policy consistently for history capture, resume, prompt preparation, and review input budgeting. Keep fixed budgeting as the default. ## Testing Add configuration validation tests, capture-and-resume coverage for both budgeting modes, and a request-history snapshot verifying retained instructions and transcript section limits. GitOrigin-RevId: c7b0bdfd3e0e008d75c4d8a204959bcc58eb1bf8
This commit is contained in:
@@ -145,10 +145,27 @@ pub struct GuardianV2ReviewScopeConfigToml {
|
||||
pub sandboxed_exec_commands: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct GuardianElasticSectionConfigToml {
|
||||
pub min_total_section_tokens: usize,
|
||||
pub max_section_entry_tokens: usize,
|
||||
/// Upper bound for the section's allocation.
|
||||
/// Omit to use the global request budget as the upper bound.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub max_total_section_tokens: Option<usize>,
|
||||
}
|
||||
|
||||
/// User-configurable prompt, approval, and context settings for Guardian v2.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq, JsonSchema)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct GuardianV2ConfigToml {
|
||||
/// Enable elastic allocation for synchronous Guardian requests. Defaults to false.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub sync_elastic_budgeting: Option<bool>,
|
||||
/// Named section limits, decoded and validated by Guardian when the switch is enabled.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub sync_elastic_sections: Option<BTreeMap<String, GuardianElasticSectionConfigToml>>,
|
||||
/// Transcript encoding for synchronous Guardian review and asynchronous scoring. Defaults to line.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub transcript_mode: Option<codex_protocol::TranscriptFormat>,
|
||||
|
||||
@@ -24,6 +24,7 @@ pub use feature_configs::ContextManagementConfigToml;
|
||||
pub use feature_configs::CurrentTimeReminderConfigToml;
|
||||
pub use feature_configs::CurrentTimeReminderDeliveryMode;
|
||||
pub use feature_configs::CurrentTimeSource;
|
||||
pub use feature_configs::GuardianElasticSectionConfigToml;
|
||||
pub use feature_configs::GuardianV2ConfigToml;
|
||||
pub use feature_configs::GuardianV2ReviewScopeConfigToml;
|
||||
pub use feature_configs::GuardianV2TranscriptConfigToml;
|
||||
|
||||
@@ -329,6 +329,8 @@ max_recent_non_user_entries = 12
|
||||
assert_eq!(
|
||||
features.guardianv2,
|
||||
Some(FeatureToml::Config(crate::GuardianV2ConfigToml {
|
||||
sync_elastic_budgeting: None,
|
||||
sync_elastic_sections: None,
|
||||
transcript_mode: None,
|
||||
async_classifier_mode: None,
|
||||
async_classifier_conversation_token_limit: Some(120_000),
|
||||
|
||||
Reference in New Issue
Block a user