mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +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:
@@ -38,6 +38,7 @@ async fn guardian_checkpoint_preserves_live_context_without_storage(
|
||||
state.history = ContextManager::for_session(
|
||||
/*root_capabilities_restricted*/ false,
|
||||
&crate::config::ManagedFeatures::from(codex_features::Features::with_defaults()),
|
||||
codex_guardian_context::ContextBudgeting::Fixed,
|
||||
uuid_v7_item_id_generator_for_test(),
|
||||
);
|
||||
state
|
||||
@@ -110,6 +111,7 @@ async fn guardian_checkpoint_preserves_live_context_without_storage(
|
||||
fork.state.lock().await.history = ContextManager::for_session(
|
||||
/*root_capabilities_restricted*/ false,
|
||||
&crate::config::ManagedFeatures::from(codex_features::Features::with_defaults()),
|
||||
codex_guardian_context::ContextBudgeting::Fixed,
|
||||
uuid_v7_item_id_generator_for_test(),
|
||||
);
|
||||
fork.record_initial_history(InitialHistory::Forked(items))
|
||||
|
||||
@@ -199,6 +199,7 @@ impl Session {
|
||||
ContextManager::for_session(
|
||||
turn_context.root_capabilities_restricted,
|
||||
&turn_context.config.features,
|
||||
turn_context.config.guardian_context_budgeting(),
|
||||
std::sync::Arc::clone(&self.item_id_generator),
|
||||
),
|
||||
turn_context.model_info().truncation_policy.into(),
|
||||
|
||||
@@ -129,6 +129,7 @@ async fn sender_context_follows_its_delivery_through_checkpoint_and_rollback() {
|
||||
let mut live = ContextManager::for_session(
|
||||
/*root_capabilities_restricted*/ false,
|
||||
&crate::config::ManagedFeatures::from(codex_features::Features::with_defaults()),
|
||||
codex_guardian_context::ContextBudgeting::Fixed,
|
||||
uuid_v7_item_id_generator_for_test(),
|
||||
);
|
||||
let mut items = Vec::new();
|
||||
|
||||
@@ -1640,6 +1640,7 @@ impl Session {
|
||||
ContextManager::for_session(
|
||||
session_configuration.root_capabilities_restricted,
|
||||
&config.features,
|
||||
config.guardian_context_budgeting(),
|
||||
Arc::clone(&item_id_generator),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -6927,6 +6927,7 @@ pub(crate) async fn make_session_and_context() -> (Session, TurnContext) {
|
||||
state.history = ContextManager::for_session(
|
||||
session_configuration.root_capabilities_restricted,
|
||||
&config.features,
|
||||
config.guardian_context_budgeting(),
|
||||
Arc::clone(&item_id_generator),
|
||||
);
|
||||
let (environment_manager, resolved_environments) =
|
||||
@@ -9270,6 +9271,7 @@ where
|
||||
state.history = ContextManager::for_session(
|
||||
session_configuration.root_capabilities_restricted,
|
||||
&config.features,
|
||||
config.guardian_context_budgeting(),
|
||||
Arc::clone(&item_id_generator),
|
||||
);
|
||||
let (environment_manager, resolved_turn_environments) =
|
||||
|
||||
Reference in New Issue
Block a user