Skip to content

[codex] Reuse compacted history replacement for new context windows - #29762

Merged
pakrym-oai merged 1 commit into
mainfrom
pakrym/start-new-context-window-compaction
Jun 24, 2026
Merged

[codex] Reuse compacted history replacement for new context windows#29762
pakrym-oai merged 1 commit into
mainfrom
pakrym/start-new-context-window-compaction

Conversation

@pakrym-oai

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

Copy link
Copy Markdown
Contributor

Why

start_new_context_window independently replaced in-memory history and persisted a compacted checkpoint instead of using the shared compacted-history path. That bypassed the centralized missing-item-ID assignment when item_ids is enabled, so fresh context messages could enter the new context window and its persisted replacement history without IDs.

This follows up on the token-budget compaction reset flow introduced in #29743.

What changed

  • Delegate new context-window installation to replace_compacted_history.
  • Reuse its ID assignment, in-memory replacement, world-state baseline, checkpoint persistence, turn-context persistence, and session-start bookkeeping.
  • Add focused coverage that verifies generated IDs are present in live history and preserved in the persisted replacement history.

Testing

  • just test -p codex-core start_new_context_window_assigns_and_persists_item_ids
  • just test -p codex-core new_context_tool_starts_new_window_before_follow_up

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

@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: b857fe20cd

ℹ️ 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
CompactedItem {
message: String::new(),
replacement_history: Some(replacement_history),
replacement_history: None,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why isn't this set anymore?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it's set inside replace_compacted_history call.

@pakrym-oai
pakrym-oai merged commit 176af2b into main Jun 24, 2026
31 checks passed
@pakrym-oai
pakrym-oai deleted the pakrym/start-new-context-window-compaction branch June 24, 2026 01:53
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 24, 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