Skip to content

[Feature]: Offer quota-safe compaction recovery when switching providers #7850

Closed

Description

@LuizPiccini

Proposal: make provider switches recover gracefully when the previous provider cannot compact

This proposes a usability/default-policy improvement. The original failure was observed on OpenCodex 2.64.0; default behavior has not been reproduced on 2.93.0 with routing overrides disabled.

Area

Proxy and routing; compaction recovery UX.

Relationship to existing issues

This builds on closed issues #2723 and #5012 rather than asking for their fixes again. #2723 was resolved by #2858 with a bounded session-lane retry to a previously successful compact target on body-confirmed quota failure. #5012 was resolved by #5202 with explicit opt-in compactionRouting for manual and automatic triggers. The remaining request here is to make that supported recovery policy discoverable during a blocked provider switch, with portable checkpoints and clear bounded failure messages. It does not claim those earlier fixes are absent.

Observed failure

On Windows, two existing Codex Desktop conversations using Anthropic subscription models exhausted the provider's five-hour allowance. Selecting an OpenAI model triggered pre-turn ModelDownshift compaction. The Codex runtime issued the compaction request using the previous Anthropic selector, which returned HTTP 429. The user saw compaction remain pending rather than reaching the selected model. Both attempts were eventually interrupted.

A temporary compactionRouting override to an available OpenAI subscription recovered one conversation. The other exposed a separate replay validation failure:

Missing required parameter: input[N].content[0].annotations[M].title

Supplying a missing URL citation title during outbound translation allowed that conversation to recover too. No stored messages were manually modified.

Existing upstream work

The citation defect is already addressed by merged PR #7573, with destination-boundary refinements in #7682. Both are included in the current installed official 2.93.0 sources. This should not be filed as a new unfixed citation bug.

PR #6236 addresses unnecessary native/routed switching compaction caused by synthetic compatibility hashes. It does not eliminate genuine context-window downshift compaction.

Useful primary references:

Supported workaround tested on 2.93.0

Use a persistent, opt-in compactionRouting policy covering both auto and manual triggers. Target a failover combo whose provider/account targets the operator explicitly approves. A combo forces portable ocx1: summaries even when the first compactor is the same provider as the source; this matters for later switches in the opposite direction. Normal response requests keep their selected models.

For this installation the approved targets are existing OpenAI and Anthropic subscriptions, with no paid API-key target and no wait for all-target cooldown. Other installations must choose their own targets; there should be no new cross-provider disclosure or spend by default.

Suggested improvement

Offer a discoverable quota-safe compaction preset or recovery action when the previous provider is quota-blocked during a model switch. Where the user's configuration explicitly approves alternate providers, make compaction use an available target and retain a portable checkpoint. Where no eligible target exists, return a clear bounded error with the quota/reset reason instead of appearing to compact indefinitely. Do not bypass policy refusals, cancellations, credential ownership or approved disclosure boundaries.

Codex owns the decision to compact using the previous model. OpenCodex can route the compaction request but should not infer an uncommunicated destination. If automatic target-aware switching needs a protocol addition, coordinate that distinction upstream rather than treating it as entirely an OpenCodex defect.

Suggested regression cases

  • Previous Anthropic target returns 429, approved OpenAI compactor succeeds.
  • Previous OpenAI target returns 429, approved alternate subscription succeeds.
  • First compactor cannot fit the input; a configured larger-context target is eligible.
  • Both manual and automatic compaction return one portable checkpoint; ordinary requests remain unchanged.
  • Checkpoint can be replayed by the next provider, including switches in the reverse direction.
  • Old URL citations missing titles compact successfully on OpenAI-operated destinations, while gateway-owned annotation fields remain untouched.
  • All approved compactors unavailable: bounded failure with a useful explanation.
  • User cancels or origin/policy refuses: no failover that bypasses that decision.

Validation boundary

Live synthetic auto compaction naming Anthropic and manual compaction naming OpenAI both succeeded on the configured portable combo and preserved exact checkpoint markers. Deterministic local checks cover six source selectors, both triggers and both compact surfaces, portable replay parsing in three model formats, citation repair, quota/context failure decisions, cancellation/origin stops and config reload. No live quota was deliberately exhausted. These checks validate the configured workaround; they do not establish a remaining default-mode bug in 2.93.0.

Activity

  1. coderabbitai commented on Oct 27, 2026

    @coderabbitai
    Contributor
    🔗 Related PRs

    #7765 - fix(codex): route compaction through compactionRouting for Gemini targets [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
    account-pool
    on Oct 27, 2026
  3. LuizPiccini commented on Oct 28, 2026

    @LuizPiccini
    Author

    Follow-up: compaction also stalled after resuming a session stopped by quota exhaustion, without a new provider switch. There are two distinct cases below.

    1. Compaction combo remains unavailable after direct requests resume (Windows, 2.93.0)

    The compactionRouting override from this issue was already installed for both auto and manual triggers, pointing to a failover combo with OpenAI and Anthropic subscription targets and waitForCooldownMs: 0.

    After quota failures, subsequent compaction attempts returned:

    requestedModel=combo/portable-compaction
    status=503
    errorCode=server_is_overloaded
    durationMs=151
    No available targets for combo: portable-compaction
      openai/gpt-6.1-sol: cooldown 84692s
      anthropic/claude-fable-5-1: cooldown 3835s
    

    Ordinary requests to openai/gpt-6.1-sol were returning 200 during this period. This is evidence of differing route availability; it does not by itself establish that every request used the same underlying account or that a quota protection rule was incorrect.

    The proxy failed quickly, but the desktop remained in its compaction state until interrupted: one attempt lasted about 22 minutes, another about 72 seconds. I have not isolated whether this reflects client retries, response/error handling, or a UI state problem, so I am not claiming that a single proxy request ran indefinitely.

    Enabling the existing combo setting below allowed live synthetic automatic and manual compaction checks to succeed again:

    {
      "waitForCooldownMs": 0,
      "cooldownReprobe": {
        "enabled": true,
        "intervalMs": 300000
      }
    }

    The setting applies only to the dedicated compaction combo. It permits a bounded recovery pass when all eligible targets are cooled; provider quota enforcement and account admission still apply. No package source patch was needed. The user subsequently reported that the real session was progressing through compaction; final completion was not independently verified.

    2. All configured subscription compactors really are unavailable (Linux)

    A separate Linux installation had two reported stuck sessions, OpenCodex 2.82.0, and no compactionRouting override. Logs showed OpenAI blocked by the configured main-account quota protection and Anthropic returning 429.

    After updating to 2.93.0 and installing the subscription-only compaction combo, a synthetic compaction request still returned 429. Reprobing cannot make an exhausted or policy-blocked account available.

    With explicit user approval, an already-configured Xiaomi MiMo Token Plan target (mimo/mimo-v2.6-pro) was added as the third compactor. Both synthetic checks then returned 200 through the combo, with usage records confirming resolvedModel=mimo-v2.6-pro. They covered automatic compaction naming an Anthropic source and manual compaction naming an OpenAI source; each returned one portable checkpoint and preserved its test marker. Both real sessions still needed a user retry at the end of verification.

    Suggested additions to this issue

    • Make the supported cooldown-reprobe option discoverable in the proposed compaction recovery flow. Consider whether successful requests can invalidate obsolete combo cooldown evidence, only where account/model identity and the original failure scope actually match.
    • Distinguish an all-cooled combo from generic server overload in the surfaced error. Explain which compactors are unavailable and offer an actionable retry/reset reason.
    • Verify that terminal compaction failures leave the client with a visible bounded error instead of an apparently persistent compaction state. This may require coordination with the Codex client.
    • Test quota exhaustion followed by resume, without a provider change; direct-route recovery while the combo remains cooled; concurrent requests respecting the reprobe interval; and all targets genuinely unavailable.
    • Keep alternate-provider use opt-in: adding MiMo changes the destination receiving conversation history. Do not disable quota protection or silently add paid/API targets to make recovery succeed.

    The configured policy also passed 24 deterministic routing cases. These observations validate the workaround and identify recovery UX/error-handling gaps; they do not prove a general default-routing regression in 2.93.0. No real conversation contents, account identifiers, credentials, or private host details are included here.

  4. lidge-jun commented on Oct 28, 2026

    @lidge-jun
    Owner

    At dev fdc6dd82d930295880dcf6d10bbb9f2c61994574, #2858/#5202, citation repairs #7573/#7682 and compatibility-hash repair #6236 are already merged. compactionRouting already supports trigger/source selection (src/server/responses/compaction-routing.ts:55), and a combo forces portable handling (:126). Separate opt-in compactionRecovery already exists, with native/combo/policy exclusions (src/server/responses/compaction-recovery.ts:67). #7765 is now closed/withdrawn. These are not missing features to reimplement.

    The follow-up exposes a real source-level recovery gap, although its specific incident is not proven. A local Codex cooldown emits Retry-After (src/codex/auth-context.ts:993). Authentication can return that refusal before account attribution (src/server/responses/request-prepare.ts:1557, :1581). Combo failure handling therefore lacks the account label needed for its account-scoped exemption (src/server/responses/core-combo.ts:1403; src/combos/resolve.ts:528), and records the delay against the target. src/combos/failover.ts:285 preserves that header up to 24 hours. Thus 84692 seconds is possible; the number alone does not identify its origin.

    Direct success cannot clear this record: it is keyed by combo/provider/model, without credential identity (src/combos/failover.ts:14, :53). Successful reserved reprobes clear only their unchanged revision (src/combos/resolve.ts:477). Anthropic already has a local-pool refusal exception (src/server/responses/core-combo.ts:1415), but the checked code has no Codex counterpart.

    Three options follow:

    • Surface the existing opt-in cooldownReprobe in recovery guidance for an explicitly approved compaction combo. feat(combos): add opt-in cooldown recovery with configurable interval #7723/fix(combos): scope cooldown reprobes to reserving request #7764 already supply bounded, request-owned recovery; no new default or provider destination is needed.
    • Distinguish internally generated Codex quota refusals from upstream failures and use the capped local combo backoff for those alone, retaining account admission and the client's reset information. This prevents local account evidence from becoming a day-long target quarantine.
    • Clear on direct success. This needs matching physical credential, model, failure scope and generation receipts that the cooldown record currently lacks; selector equality is insufficient.

    I recommend the first option for discoverability and the second as the smallest code repair. Add internal response provenance at codex-auth-error.ts, carry it through core-combo-failure.ts/core-options.ts, and consume it in core-combo.ts; use a leaf helper if needed. Do not trust an upstream-spoofable header. A new tests/server/server-combo-local-codex-cooldown.test.ts should prove local 429 then account recovery permits selection after capped backoff, while genuine upstream long delays, other-account success, newer cooldown revisions and all-exhausted admission remain protected. Register both test-layout entries. Terminal-client/UI behavior needs separate reproduction. No runtime reproduction or test pass is claimed here.

  5. lidge-jun commented on Nov 11, 2026

    @lidge-jun
    Owner

    Closed by #8537. The source-level repair from the analysis above landed as #7887: a local Codex Pool cooldown refusal now carries process-local provenance, so a combo target is cooled only for the short combo backoff instead of the account Retry-After (tests/server/server-combo-cooldown-recording.test.ts, 19/19 on current dev). #8522 made combo_unavailable name the earliest recovery on the Responses and Claude Messages listeners. #8537 documents the opt-in cooldownReprobe recovery for a dedicated compaction combo in the compactionRouting reference. Client or UI behavior while a compaction stays pending was not reproduced here; please open a new issue with a reproduction if it persists.

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

    account-poolenhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions