mirror of
https://github.com/openai/codex.git
synced 2026-11-14 21:40:39 +00:00
## What changed - Add `async_elastic_budgeting` and `async_elastic_sections` under `[features.guardianv2]`, independently of synchronous budgeting and disabled by default. - Apply section limits and elastic allocation to new classifier evidence after accounting for setup and retained conversation history. Preserve the configured elastic policy when applying model defaults. - Keep permission context whole during elastic allocation and record truncation observations when image preparation rejects an image. ## Testing Add coverage for configuration validation, fixed and elastic conversation budgeting, retained history and cursor preservation, and complete classifier requests that retain evidence beyond the fixed entry limit. GitOrigin-RevId: 2955f0482f7c3e18325e296fc2ccb6592ffcb73a
24 lines
993 B
Rust
24 lines
993 B
Rust
//! Shared fixture with a larger transcript message cap and fallback limits elsewhere.
|
|
|
|
use codex_guardian_context as context;
|
|
|
|
pub fn elastic_budget_config() -> context::ElasticBudgetConfig {
|
|
const MESSAGE_ENTRY_TOKENS: usize = 4_000;
|
|
let mut config = context::ElasticBudgetConfig::default();
|
|
let fallback = usize::try_from(config.total_minimum_tokens()).expect("token total fits usize");
|
|
let limits = context::ContextProfile::synchronous()
|
|
.transcript
|
|
.entry_limits;
|
|
let minimum = context::DEFAULT_MAX_INPUT_TOKENS - (fallback - limits.message_tokens);
|
|
config.sections.insert(
|
|
context::ElasticSection::TranscriptMessages,
|
|
context::ElasticSectionLimits::new(minimum, MESSAGE_ENTRY_TOKENS).expect("valid limits"),
|
|
);
|
|
config
|
|
}
|
|
|
|
pub fn async_elastic_sections_toml() -> String {
|
|
let sections = toml::Value::try_from(elastic_budget_config().sections).expect("encode limits");
|
|
format!("async_elastic_sections = {sections}")
|
|
}
|