Skip to content

Add a fallback phase before automatic context rollover - #33255

Merged
copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/32983ecadc5cb4927e15ecd7b1e896cb52a9ad3b
Jul 15, 2026
Merged

Add a fallback phase before automatic context rollover#33255
copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/32983ecadc5cb4927e15ecd7b1e896cb52a9ad3b

Conversation

@copyberry

@copyberry copyberry Bot commented Jul 15, 2026

Copy link
Copy Markdown

Add a fallback phase before automatic context rollover

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.

## 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
@copyberry
copyberry Bot force-pushed the copyberry/codex-internal-to-codex-oss/32983ecadc5cb4927e15ecd7b1e896cb52a9ad3b branch from 43199cc to 768330d Compare July 15, 2026 05:46
@copyberry
copyberry Bot merged commit 768330d into main Jul 15, 2026
14 of 32 checks passed
@copyberry
copyberry Bot deleted the copyberry/codex-internal-to-codex-oss/32983ecadc5cb4927e15ecd7b1e896cb52a9ad3b branch July 15, 2026 05:48
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants