[compaction] normalize legacy context compaction history#23785
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7b9bc73b7b
ℹ️ 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".
| ResponseItem::CompactionTrigger => false, | ||
| ResponseItem::Other => false, | ||
| | ResponseItem::Compaction { .. } => true, | ||
| ResponseItem::ContextCompaction { .. } |
There was a problem hiding this comment.
Preserve encrypted context_compaction during replay
When resuming an older rollout, rollout_reconstruction.rs replays each persisted RolloutItem::ResponseItem through history.record_items(...), which first calls this predicate. Returning false here drops every legacy context_compaction item before for_prompt() can run normalize_legacy_context_compaction_items, so sessions whose suffix contains {"type":"context_compaction","encrypted_content":...} lose the compacted encrypted summary instead of converting it to ResponseItem::Compaction, leaving the resumed prompt without the compacted prior context.
Useful? React with 👍 / 👎.
7b9bc73 to
38f370a
Compare
|
Codex Review: Didn't find any major issues. Nice work! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Why
This follows up on #22809.
Older persisted sessions can still contain
context_compactionhistory items from before the remote-compaction wire contract moved tocompaction_triggerinputs andcompactionoutputs. If those legacy items are sent through the prompt path unchanged, the backend rejects the request with an invalid enum error, which can leave compaction retrying and consuming quota.Issues resolved:
context_compaction, consuming quota across sessions #23018What changed
ResponseItem::ContextCompactionentries before prompt history is prepared.ResponseItem::Compactionentries so compacted history survives.context_compactionentries as non-API messages alongsidecompaction_trigger.Verification
legacy_context_compaction_items_are_not_sent_to_promptincodex-rs/core/src/context_manager/history_tests.rs.