Skip to content

core: add context window lineage IDs#29256

Merged
pakrym-oai merged 2 commits into
mainfrom
pakrym/token-budget-window-lineage
Jun 20, 2026
Merged

core: add context window lineage IDs#29256
pakrym-oai merged 2 commits into
mainfrom
pakrym/token-budget-window-lineage

Conversation

@pakrym-oai

Copy link
Copy Markdown
Contributor

Why

The rendered <token_budget> fragment identifies the thread and current context window, but it does not expose enough lineage to identify the first window in the thread or the immediately preceding window. Those IDs also need to remain stable across compaction, resume, and rollback.

What changed

  • Track first, previous, and current UUIDv7 context-window IDs in auto-compaction state.
  • Render thread_id, first_window_id, previous_window_id, and the current window ID in the full <token_budget> fragment.
  • Persist the first and previous window IDs in compacted rollout checkpoints and restore them during rollout reconstruction.
  • Preserve compatibility with older compacted records that do not contain the new optional fields.
  • Update focused state, rendering, reconstruction, rollback, and serialization coverage.

Validation

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

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

@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: 0ae53e8128

ℹ️ 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
@pakrym-oai
pakrym-oai merged commit d1209bd into main Jun 20, 2026
46 of 47 checks passed
@pakrym-oai
pakrym-oai deleted the pakrym/token-budget-window-lineage branch June 20, 2026 20:15
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 20, 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