Skip to content

feat(codex): add manual native compaction for OAuth - #106327

Open
cucurigoo wants to merge 2 commits into
NousResearch:mainfrom
cucurigoo:feat/manual-oauth-native-compaction
Open

cucurigoo wants to merge 2 commits into
NousResearch:mainfrom
cucurigoo:feat/manual-oauth-native-compaction

Conversation

@cucurigoo

@cucurigoo cucurigoo commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add CLI-only /native-compact (/compact-native) for eligible ChatGPT Codex OAuth sessions
  • call OpenAI’s standalone responses.compact endpoint immediately rather than waiting for the automatic threshold
  • keep Hermes’ complete readable transcript; persist the encrypted checkpoint only as a route-scoped replay projection

Design

This deliberately differs from the rejected Responses half of #54633 / #33130. Current main already supports opt-in automatic native checkpoints; this command reuses that existing projection and cross-issuer drop path. The portable local history stays authoritative, so provider/model switching simply drops the checkpoint instead of losing the compacted prefix.

The command is intentionally CLI-only and requires the existing native gate: official Codex OAuth route, gpt-5.6, compression.enabled: true, and compression.codex_responses_native: true. It does not change automatic compaction behavior. Repeated manual compaction replaces the prior checkpoint on its retained carrier, preserving the carrier’s encrypted reasoning after the new checkpoint.

Verification

  • scripts/run_tests.sh tests/agent/test_manual_native_compaction.py tests/cli/test_native_compact.py tests/cli/test_slash_dispatch_table.py tests/run_agent/test_native_compaction.py — 82 passed
  • ruff check on all changed Python files — passed
  • GitHub CI passed: Python tests/lints, docs, Windows/macOS-only tests, Nix, Docker build, and supply-chain checks

Related

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint area/compression Context compression and continuation sessions provider/openai OpenAI / Codex Responses API labels Sep 9, 2026
@Enough1122

Copy link
Copy Markdown
Contributor

AI code review — automated review for reference; please use your judgment.

Summary

Adds manual native compaction for Codex OAuth sessions (agent/native_compaction.py::manual_native_responses_compaction): issues an immediate responses.compact call over the message prefix and stores the returned checkpoint on an existing retained assistant turn (sidecar), leaving the readable local transcript untouched. Strict eligibility gates (Responses transport, Codex backend, model/config support, SDK capability, 401-refresh retry).

Findings

No blocking issues.

  • Transcript safety: _manual_native_compaction_carrier requires a completed assistant turn strictly before the protected tail and reuses it as carrier rather than synthesizing a turn — preserves role alternation. Failure modes raise RuntimeError with actionable messages instead of half-applying. Good.
  • Request hardening parity: the compact call rebuilds api_kwargs through the same sanitize + preflight_kwargs path as ordinary Codex requests (surrogate/ASCII/Harmony handling), and only forwards a fixed allowlist of keys (model, input, instructions, prompt_cache_key, timeout, extra_headers). Thoughtful — no prompt-injection or credential widening via the new call.
  • Non-blocking: confirm the sidecar checkpoint is actually dropped on provider/model switch as the docstring claims (projection logic in the Responses adapter isn't in this diff); if a stale checkpoint ever attached to a non-Codex request, the provider would likely reject unknown items — fail-visible, but worth a test if not already covered elsewhere.

Verdict

Careful implementation. Non-blocking note on switch-drop coverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/compression Context compression and continuation sessions comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have provider/openai OpenAI / Codex Responses API type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants