Skip to content

core: add UUIDv7 context window IDs#28953

Merged
pakrym-oai merged 2 commits into
mainfrom
pakrym/window-id-uuidv7
Jun 19, 2026
Merged

core: add UUIDv7 context window IDs#28953
pakrym-oai merged 2 commits into
mainfrom
pakrym/window-id-uuidv7

Conversation

@pakrym-oai

Copy link
Copy Markdown
Collaborator

Why

The token-budget context currently identifies a context window by its thread-local sequence number. A UUIDv7 gives the model a stable opaque identity that remains fixed for a window and rotates when compaction or new_context starts the next one.

What changed

  • Preserve the existing monotonic value as window_number and add a UUIDv7 window_id to CompactedItem.
  • Generate and rotate the UUID with auto-compaction window state, persist it alongside the number, and reconstruct it on resume and rollback.
  • Accept legacy compacted rollout records where the numeric window_id represented the window number.
  • Use the UUID only in token-budget context; existing request headers and metadata continue using thread_id:window_number.

Testing

  • just test -p codex-protocol compacted_item::tests
  • just test -p codex-core token_budget

@pakrym-oai pakrym-oai requested a review from a team as a code owner June 18, 2026 18:39

@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: 2948e39163

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread codex-rs/core/src/session/mod.rs
active_segment.get_or_insert_with(ActiveReplaySegment::default);
if active_segment.window_id.is_none() {
active_segment.window_id = compacted.window_id;
if active_segment.window.is_none()

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.

if the rollout that we resume hasn't compacted yet - we get a different window UUID? I think that's not an issue in practice, but just calling out in case.

@pakrym-oai pakrym-oai merged commit 5c12034 into main Jun 19, 2026
31 checks passed
@pakrym-oai pakrym-oai deleted the pakrym/window-id-uuidv7 branch June 19, 2026 00:00
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 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