mirror of
https://github.com/openai/codex.git
synced 2026-12-06 01:10:58 +00:00
Support fractional rollout budgets and configurable context reminders (#61579)
## What changed - Add a positive, finite `features.rollout_budget.limit_budget` allowance while retaining `limit_tokens` compatibility. Reject configurations that specify both. - Preserve fractional balances in reminders and compare thresholds without rounding the balance down. - Accumulate charges with compensated summation and allow spending exactly the allowance, including floating-point rounding tolerance for cases such as `0.1 + 0.2` against `0.3`. - Add `reminder_at_context_start`, defaulting to `true`. Set it to `false` to suppress reminders at thread start and after compaction; combine it with an empty threshold list to disable budget reminders entirely. ## Testing Extend configuration and rollout-budget tests to cover fractional allowances, legacy integer persistence, invalid limits, threshold-only reminders, and enforcement at decimal equality and after overspending. GitOrigin-RevId: b8e7a2faa8d39e562bcae196364de419698bc67d
This commit is contained in:
@@ -3,9 +3,9 @@ use codex_protocol::models::ContentItem;
|
||||
use codex_protocol::models::ContentItemKind;
|
||||
use codex_protocol::models::input_text;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub(crate) struct RolloutBudgetContext {
|
||||
pub(crate) remaining_tokens: i64,
|
||||
pub(crate) remaining_units: f64,
|
||||
}
|
||||
|
||||
impl ContextualUserFragment for RolloutBudgetContext {
|
||||
@@ -26,9 +26,10 @@ impl ContextualUserFragment for RolloutBudgetContext {
|
||||
}
|
||||
|
||||
fn body(&self) -> ContentItem {
|
||||
// "Weighted tokens" is the legacy wording. Provider-reported units can be opaque.
|
||||
input_text(format!(
|
||||
"You have {} weighted tokens left in the shared session token budget.",
|
||||
self.remaining_tokens
|
||||
self.remaining_units
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user