Skip to content

Reduce repeated Codex uploads and lossless continuation spill traffic #7905

Closed

Description

@Hylouis233

Area

Streaming; proxy and routing; continuation storage

What are you trying to accomplish?

Keep long-running native Codex sessions from repeatedly uploading the same history, and reduce continuation-cache disk writes without losing replayable context. Ship the behavior upstream so normal package upgrades do not remove locally maintained optimizations.

What prevents this today?

An opt-in upstream WS continuation can already omit an acknowledged, exactly matching input prefix, but the current local extension retires idle sockets after three minutes and by twenty minutes of total age. A later request then uploads the whole history again even when its model, admitted caller, account, thread and route are unchanged.

Local continuation storage also retains cumulative input/output records per response ID. Large repeated records create substantial spill traffic. Merely increasing the cache budget postpones eviction and retains more duplicated data.

What should OpenCodex do?

  • Keep completed, eligible connections warm for a bounded longer interval when incremental upload is enabled, without raising socket-count, exchange-count or retained-prefix memory limits.
  • Continue only from a completed response belonging to the same admitted caller and unchanged history/envelope. Preserve account/credential/route isolation, cancellation and UNKNOWN/failure behavior.
  • Store profitable continuation spill records losslessly in bounded, self-contained compressed envelopes. Preserve legacy reads, original item content, response IDs, thread isolation and decoded-size limits; do not create fragile parent-file dependencies.
  • Include this behavior in the supported release path. A local workaround should refuse an incompatible update before replacement rather than silently start an unpatched package.

Example usage or interface

With codexWsIncrementalUpload: true, an isolated test using real Bun WebSockets sends two otherwise equivalent requests with a simulated four-minute idle gap:

Measurement Original retention Longer bounded retention
First create bytes 278,631 278,631
Second create bytes 278,751 148
Physical connections 2 1
Logical creates 2 2

For storage, a bounded read-only sample of eight existing continuation records encoded from 20,913,583 to 14,245,022 bytes (31.9% fewer physical bytes), with exact decoded-content equality. This is a sample, not a promised production reduction. WS JSON savings are not billing savings, whole-interface traffic, or a comparison against compressed HTTP.

Alternatives or workarounds

Local source patches demonstrate the benefit but can be replaced by package upgrades. Blanket history truncation changes the model's context; retaining more raw snapshots increases resource use. Self-contained compression avoids introducing cross-file recovery dependencies. Older readers cannot decode the new envelopes, so rollback must retain the decoder until those records expire.

Additional context

Related implementation: #7806. The follow-up preserves its admitted-caller scoping and live-config binding fixes. Local validation uses synthetic loopback providers and isolated storage; no production prompts, credentials or account identifiers are included.

Checks

  • I searched existing issues and documentation.
  • This request describes a concrete OpenCodex workflow rather than merely naming a desired technology.
  • I removed secrets and personal data.

Activity

  1. coderabbitai commented on Oct 28, 2026

    @coderabbitai
    Contributor
    🔗 Related PRs

    #7806 - feat(codex): reduce uploads with optional history slimming and WS deltas [open]


    📝 Issue Planner

    Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

    • Create Plan

    🧪 Issue enrichment is currently in open beta.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

  2. added
    enhancement
    streaming
    on Oct 28, 2026
  3. Hylouis233 commented on Oct 29, 2026

    @Hylouis233
    ContributorAuthor

    Update-preservation verification was rechecked on macOS arm64 without installing a production update or restarting the running service.

    • Downloaded the actual clean npm 2.93.0-preview.20261027 archive and verified its published SHA-512 integrity. It initially contained neither the local traffic extension nor its pre-swap guard hook.
    • The external guard restored the compatible recipe and the next-update hook in an isolated candidate. All 16 behavior checks passed (67 assertions), covering incremental continuation, history/failure boundaries, large HTTP zstd diagnostics and lossless spill storage.
    • The separate eight-test maintenance suite passed two consecutive synthetic compatible transactions and an incompatible candidate. The incompatible candidate performed zero live-directory renames and kept the old package. These synthetic successor labels are not claims about real future versions.
    • A repeatable clean-release verification entrypoint is retained outside the npm installation. Protected live-file hashes stayed unchanged; production updates and restarts were zero.

    The guarantee is deliberately bounded: native ocx update / dashboard transactions using that updater are protected; direct npm install -g, other package managers and manual replacement bypass it. An incompatible candidate is refused rather than silently adopted without the extensions. This external guard remains a local workaround; #7806 upstreams the functionality and does not contain a machine-specific updater hook.

    #7806 was also refreshed against current dev and its previously failing source-inventory CI regression was fixed at 6a1dc5c53fc92a2002f07ab84d1a9bac1842b59c. Current local verification includes 235 passing focused transport/config/storage cases, passing source/layout checks and typecheck. The PR remains draft for the outstanding independent security review and exact-head hosted CI; it is not represented as merged or fully approved.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementstreaming

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions