Skip to content

Add body_after_prefix auto-compact token limit scope#22870

Merged
jif-oai merged 9 commits into
mainfrom
jif/more-compat-mech
May 19, 2026
Merged

Add body_after_prefix auto-compact token limit scope#22870
jif-oai merged 9 commits into
mainfrom
jif/more-compat-mech

Conversation

@jif-oai
Copy link
Copy Markdown
Collaborator

@jif-oai jif-oai commented May 15, 2026

Why

model_auto_compact_token_limit has only been able to budget the full active context. That makes it hard to set a small "growth since compaction" budget for sessions that preserve a large carried window prefix: the preserved prefix can consume the whole budget and force immediate repeated compaction.

This PR adds an opt-in body_after_prefix scope so callers can apply model_auto_compact_token_limit to sampled output and later growth after the current carried prefix, while still forcing compaction before the full model context window is exhausted.

What changed

  • Adds AutoCompactTokenLimitScope with the existing total behavior as the default and a new body_after_prefix mode: config_types.rs.
  • Threads model_auto_compact_token_limit_scope through config loading, Config, core-api, and app-server v2 schema/TypeScript generation.
  • Records the first observed input-token count for a body_after_prefix compaction window and uses it as the baseline when deciding whether the scoped auto-compaction budget is exhausted: turn.rs.
  • Keeps a hard context-window cap in body_after_prefix, so scoped budgeting cannot let the active context overrun the usable window.

Verification

Added compact-suite coverage for the two key behaviors: body_after_prefix does not re-compact just because the carried prefix is larger than the scoped budget, and it still compacts when the total active context reaches the configured context window: compact.rs.

@jif-oai jif-oai requested a review from a team as a code owner May 15, 2026 17:13
@jif-oai jif-oai changed the title feat: add body_after_prefix Add body_after_prefix auto-compact token limit scope May 15, 2026
@jif-oai
Copy link
Copy Markdown
Collaborator Author

jif-oai commented May 15, 2026

@codex review

Copy link
Copy Markdown
Contributor

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

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: 973806b1cb

ℹ️ 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/session/turn.rs Outdated
Comment thread codex-rs/core/src/config/mod.rs
Comment thread codex-rs/core/src/session/turn.rs Outdated
@jif-oai
Copy link
Copy Markdown
Collaborator Author

jif-oai commented May 17, 2026

@codex review

Copy link
Copy Markdown
Contributor

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

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: f3b80c51e7

ℹ️ 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/session/mod.rs
Comment thread codex-rs/core/src/session/turn.rs Outdated
Comment thread codex-rs/core/src/session/turn.rs Outdated
Comment thread codex-rs/core/src/session/turn.rs
Comment thread codex-rs/core/src/session/mod.rs Outdated
Comment thread codex-rs/core/src/session/mod.rs Outdated
@jif-oai jif-oai enabled auto-merge (squash) May 19, 2026 08:47
@jif-oai jif-oai merged commit 80fdd46 into main May 19, 2026
31 checks passed
@jif-oai jif-oai deleted the jif/more-compat-mech branch May 19, 2026 10:19
@github-actions github-actions Bot locked and limited conversation to collaborators May 19, 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.

2 participants