Conversation
…daries - codex.serverCompactionPersist / CCP_CODEX_SERVER_COMPACTION_PERSIST (off by default) writes anchored state to <state dir>/codex-compaction/<session>.json and reloads it when the in-memory copy is gone (30 min TTL, restarts). - A compaction boundary reached from an anchored conversation now compacts the native history, so the previous encrypted item is carried into the next one and the portable summary is written with it in context. - Requests on the same session that do not match (subagents, another model) skip replay instead of discarding the main conversation's state. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #163. Three changes to Codex server compaction, in one commit since they touch the same few functions:
1. Opt-in disk persistence (
codex.serverCompactionPersist/CCP_CODEX_SERVER_COMPACTION_PERSIST, default off)<state dir>/codex-compaction/<session id>.jsonvia the existingauth::write_atomically(0600 file, 0700 dir).apply_compaction_replayreloads it when the in-memory entry is missing (TTL eviction or restart). The in-memory TTL and caps are unchanged; the file is only the backstop.abort_compaction_attempt), and when server compaction is disabled (clear_compaction). The failed-replay case matters: otherwise a state Codex rejects would be reloaded on every request.[A-Za-z0-9_-]{1,128}; otherwise nothing is persisted.2. Chain across boundaries (
providers/codex/mod.rs)request_compactionand the portable-summary request then see the native history instead of the previous portable summary. Each new encrypted item carries the previous one forward, and the new portable summary is written with it in context.3. Mismatched requests skip replay instead of clearing (
apply_compaction_replay)Nonewithout removing the state. Subagents share the session id (as in Codex continuation state collides across agents sharing a Claude session #95), so previously a subagent's first request discarded the main conversation's state. The oversize check still removes it.replay_clears_on_model_changeandreplay_clears_on_missing_or_duplicate_anchorare renamed toreplay_skips_*. Each now also asserts that the anchored request still replays afterwards.Docs:
providers/codex.md(new "Persist server compaction" subsection, updated fallbacks paragraph),reference/configuration.md,how-it-works.md.Testing
cargo test --release --lib compaction: 21 passed, including two new tests (persisted_state_survives_registry_loss_and_clears_with_it,persistence_is_off_by_default).cargo test --release --lib providers::codex: 412 passed.CCP_TRAFFIC_LOG=1: I seeded a persisted state for a session whose early history existed only as a Codexcompactionitem, started a fresh proxy, and resumed that session in Claude Code. The upstream capture shows the retained messages and thecompactionitem in place of the portable summary, and the portable summary text never reached upstream. The model correctly recalled details that only the encrypted item contained.Open questions for you
MAX_STATE_BYTES) until its next boundary. A max age or count cap might be wanted.ConversationIdentityas in Codex continuation state collides across agents sharing a Claude session #95 would fix that, but it's a larger change.Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com (autonomous session; opened on behalf of @Butanium)