Skip to content

fix(sse): re-enable prompt compression for native Codex passthrough - #12834

Merged
diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.51from
thomasmaerz:fix/codex-prompt-compression-v3.8.51
Sep 6, 2026
Merged

fix(sse): re-enable prompt compression for native Codex passthrough#12834
diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.51from
thomasmaerz:fix/codex-prompt-compression-v3.8.51

Conversation

@thomasmaerz

@thomasmaerz thomasmaerz commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Native Codex passthrough (POST /v1/responses, provider=codex, e.g. opencode → omniroute) silently stopped producing compression savings: 100% of codex rows in compression_analytics became skip_reason='excluded', mode='off', tokens_saved=0 while call_logs volume continued.

Root cause: Commit 32f83407 (2026-08-11, #8933) added nativeCodexPassthrough || to the prompt-compression exclusion gate. Carried onto release line via 65e81158a (v3.8.50, #11088 sync).

Fix (prompt-only scope)

open-sse/handlers/chatCore.ts: compressionExcluded no longer includes nativeCodexPassthrough; prompt compression now depends only on the operator exclusions list (#8034). Native contexts compress via the existing adaptBodyForCompression() Responses→messages adapter with codex tool-output eligibility guards. Operators who want byte-identical passthrough can add codex/* to exclusions.

Deliberately NOT changed (reactive + combo deferral)

  • Reactive proactive/last-resort compaction (!nativeCodexPassthrough gates in chatCore.ts) still bypass native passthrough. These passes rewrite history (trim_tools/purify_history) and are the overflow safety net — re-enabling them for stateful Responses contexts needs its own validation.
  • Combo overflow fail-fast (dispatchPrelude/knownContextOverflow, #10225 / #10503) still treats native-codex pools as incompressible, so oversized requests keep failing fast locally instead of sailing upstream uncompressed.
  • Net effect: normal-sized codex requests compress again (analytics return); oversized codex requests still fail fast without attempting compression. That asymmetry is intentional and pinned by the updated #10503 comments.

Regression Analysis & Verification

See issue comment: #12793 (comment)

Timeline:

Why #9200 didn't prevent this: #8933 came AFTER #9200 and added a NEW unconditional bypass that overrode the global switch #9200 introduced.

What #8933 actually fixed (verified still intact with my PR):

  1. Executor repair (codex.ts): repairMissingCodexToolCallOutputs - ensures function_call_output items exist for every function_call ✅ (43/43 tests pass)
  2. Compression bodyAdapter (bodyAdapter.ts): Enhanced to properly track/restore custom_tool_callcustom_tool_call_output pairing during compression ✅ (11/11 tests pass)
  3. Combo overflow (clientManagedResponsesContext flag): Allows native Codex clients to self-manage context overflow ✅ (17/17 tests pass, including "native Responses context reaches an all-Codex target beyond its catalog hint")

#9200 fix verified intact: Global compression "off" still gates reactive/last-resort compaction ✅ (1/1 test passes)

Validation

  • New regression guard tests/unit/codex-prompt-compression-passthrough.test.ts (3/3 pass; first assertion fails on pre-fix source).
  • Existing suites green: compression-exclusions (8/8), chatcore-request-format (9/9), combo-context-overflow-compression-probe (5/5 substantive incl. end-to-end chatCore compression dispatch; file has pre-existing teardown DB handle hang unrelated to this change), executor-codex (43/43), body-adapter (11/11), combo-context-window-filter (17/17), reactive-context-compaction-policy (1/1).

Related

Closes #12793

Native Codex passthrough (POST /v1/responses, provider=codex) was unconditionally
excluded from prompt compression, writing only skip_reason='excluded' analytics
rows. Prompt compression now depends only on the operator exclusions list;
reactive compaction and combo overflow fail-fast intentionally still bypass
(prompt-only scope).

Closes diegosouzapw#12793

Regression guard: tests/unit/codex-prompt-compression-passthrough.test.ts
@diegosouzapw
diegosouzapw merged commit 92a617c into diegosouzapw:release/v3.8.51 Sep 6, 2026
3 checks passed
alvinveroy added a commit to alvinveroy/OmniRoute that referenced this pull request Sep 6, 2026
- take upstream useSyncExternalStore combos usage-guide (diegosouzapw#12671) over our
  queueMicrotask lint defuse (supersedes it; suppression already dropped)
- file-size baseline: combos/page.tsx 5066 (upstream shape); keep both
  _rebaseline entries (bounded-abort/tls-ladder + 12671 external store)
- upstream additions folded in: diegosouzapw#12682 sqlite cleanup, diegosouzapw#12691 tool_calls
  guard, diegosouzapw#12834 codex compression re-enable, diegosouzapw#12707 continuation, diegosouzapw#12710
  video-transcript redaction, diegosouzapw#12699 npmrc shipping, docker/deps/docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(backend): Codex /v1/responses via native passthrough bypasses compression pipeline and analytics (HTTP variant of #8052)

2 participants