Skip to content

[codex] add configurable token budget compaction reminder#29255

Merged
pakrym-oai merged 9 commits into
mainfrom
pakrym/token-budget-wrap-up-reminder
Jun 21, 2026
Merged

[codex] add configurable token budget compaction reminder#29255
pakrym-oai merged 9 commits into
mainfrom
pakrym/token-budget-wrap-up-reminder

Conversation

@pakrym-oai

@pakrym-oai pakrym-oai commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Why

The token-budget feature reports coarse remaining-context milestones, but it does not give the model a configurable wrap-up prompt before automatic compaction. A strict threshold-crossing check can also miss resumed or reconfigured windows that are already inside the threshold.

What changed

  • Add structured [features.token_budget] configuration for an absolute reminder_threshold_tokens and bounded reminder_message_template; {n_remaining} is expanded when the reminder is delivered.
  • Compute remaining tokens against the next effective auto-compaction boundary, including scoped body_after_prefix accounting and the full context-window limit.
  • Make reminder delivery level-triggered before and after sampling, with one-shot state owned by AutoCompactWindow and re-armed on compaction, new_context, restore, or history replacement.
  • Leave the existing initial full-window token-budget context, 25/50/75% notices, and token-budget tools unchanged.
  • Persist the resolved feature configuration in the session config lock and regenerate the config schema.

Validation

  • just test -p codex-core token_budget
  • just test -p codex-core token_budget_reminder_emits_after_crossing_compaction_threshold
  • just test -p codex-core auto_compact_window
  • just test -p codex-core lock_contains_prompts_and_materializes_features
  • just test -p codex-features
  • just test -p codex-config

@pakrym-oai
pakrym-oai marked this pull request as ready for review June 20, 2026 20:45
@pakrym-oai
pakrym-oai requested a review from a team as a code owner June 20, 2026 20:45

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1a6f397cb8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/core/src/state/auto_compact_window.rs Outdated
Comment thread codex-rs/core/src/session/config_lock.rs
@pakrym-oai
pakrym-oai merged commit 6df037d into main Jun 21, 2026
45 of 47 checks passed
@pakrym-oai
pakrym-oai deleted the pakrym/token-budget-wrap-up-reminder branch June 21, 2026 02:13
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 21, 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.

1 participant