mirror of
https://github.com/openai/codex.git
synced 2026-11-04 08:25:29 +00:00
Add a fallback phase before automatic context rollover (#33255)
## Why Token-budget sessions need a final opportunity to preserve important state before the current context is compacted. ## What changed - When `auto_compact_fallback_prompt` is configured, reserve `auto_compact_fallback_buffer_tokens` beyond the base auto-compaction limit. - At the base limit, inject the fallback prompt once as a developer message while keeping the normal tool surface available. Continue reporting zero base-window tokens during this reserve. - Roll over when the reserve or full model context is exhausted, and skip the fallback when a new context was already requested. ## Testing Added coverage for using the fallback reserve, rolling over after it is exhausted, and bypassing the fallback for an explicit `new_context` request. GitOrigin-RevId: 32983ecadc5cb4927e15ecd7b1e896cb52a9ad3b
This commit is contained in:
1 parent
3afbd8dd45
commit
768330dd6c
10 files changed
+303
-53
No files matched your search
@@ -1154,6 +1154,16 @@ pub struct TokenBudgetConfig {
|
||||
pub auto_compact_fallback_buffer_tokens: Option<i64>,
|
||||
}
|
||||
|
||||
impl TokenBudgetConfig {
|
||||
pub(crate) fn fallback_buffer_tokens(&self) -> i64 {
|
||||
if self.auto_compact_fallback_prompt.is_some() {
|
||||
self.auto_compact_fallback_buffer_tokens.unwrap_or(0)
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for TokenBudgetConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
|
||||
Reference in new issue
Block a user