feat(agent): add Codex-native compaction paths - #54633
Closed
hmirin wants to merge 1 commit into
Closed
Conversation
Contributor
|
Merged via PR #60114 — your commit was cherry-picked onto current main with your authorship preserved in git log (main @ 87b65e2). Scope note: after maintainer review, the salvage kept the app-server half of your PR and dropped the Responses-API half. Reasoning:
Thanks for the contribution — the app-server piece closes a real P2 and the code quality made the salvage straightforward. |
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.
What does this PR do?
Adds opt-in Codex-native context compaction for Codex-backed Hermes sessions.
By default, Hermes keeps its current summary-based compressor. When users set
compression.codex_native_compaction: true, Codex sessions can compact throughthe native Codex mechanisms instead:
replay the returned encrypted compaction items on later turns.
thread/compact/start.compaction, Hermes compaction, or disabled with
compression.codex_app_server_auto.compaction lifecycle status as existing Hermes compaction.
This is intentionally opt-in to avoid changing existing model behavior or
upgrading existing configs during migration.
Related Issue
Closes #33130
Related: #25253, #40957
Type of Change
Changes Made
Codex-native compaction when
compression.codex_native_compactionis enabled.items and state persistence for compacted transcripts.
thread/compact/startsupport for manual compaction andconfigurable automatic behavior through
compression.codex_app_server_auto.plumbing for the new opt-in settings.
state.db compaction persistence, compaction logs, app-server transport
behavior, config migration, and gateway cache busting.
How to Test
Check the PR diff:
Run focused tests:
A local focused slice covering Codex Responses state/log persistence and
Codex app-server compaction passed:
python -m pytest \ tests/run_agent/test_codex_responses_compaction.py \ tests/run_agent/test_codex_app_server_compaction.py \ tests/agent/transports/test_codex_app_server_session.py::TestCompactThread::test_compact_thread_sends_rpc_and_waits_for_completion \ -q # 8 passedEarlier full fork CI passed before the final rebase:
Optional manual Codex OAuth E2E:
Using an isolated
HERMES_HOME, authenticatedopenai-codex, ran realCodex turns, then resumed a long session until native Responses compaction
triggered. Repro harness and observed result:
Logs showed:
state.dbthen had 3 active messages: encrypted compaction item, latest usermessage, and latest assistant reply. The prior 9 rows were inactive and
marked
compacted=1.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — N/AScreenshots / Logs
Earlier fork CI:
Current local checks after rebasing onto latest
origin/main: