Repository navigation
Description
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:
- fix(responses): always send a title on url_citation and repair old history on replay #7573
- fix(responses): preserve gateway citations during native compact #7682
- fix(catalog): avoid synthetic compaction on native/routed model switches #6236
- https://github.com/lidge-jun/opencodex/releases/tag/v2.93.0
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
coderabbitai commentedon Oct 27, 2026
🔗 Related PRs
#7765 - fix(codex): route compaction through compactionRouting for Gemini targets [open]
📝 Issue Planner
Check the box below or use the
@coderabbitai plancommand to generate an implementation plan and prompts that you can use with your favorite coding assistant.🧪 Issue enrichment is currently in open beta.
To disable automatic issue enrichment, add the following to your
.coderabbit.yaml:💬 Have feedback or questions? Drop into our discord!
LuizPiccini commentedon Oct 28, 2026
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
compactionRoutingoverride from this issue was already installed for bothautoandmanualtriggers, pointing to a failover combo with OpenAI and Anthropic subscription targets andwaitForCooldownMs: 0.After quota failures, subsequent compaction attempts returned:
Ordinary requests to
openai/gpt-6.1-solwere 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
compactionRoutingoverride. 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 confirmingresolvedModel=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
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.
lidge-jun commentedon Oct 28, 2026
At
devfdc6dd82d930295880dcf6d10bbb9f2c61994574, #2858/#5202, citation repairs #7573/#7682 and compatibility-hash repair #6236 are already merged.compactionRoutingalready supports trigger/source selection (src/server/responses/compaction-routing.ts:55), and a combo forces portable handling (:126). Separate opt-incompactionRecoveryalready 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:285preserves 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:
cooldownReprobein 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.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 throughcore-combo-failure.ts/core-options.ts, and consume it incore-combo.ts; use a leaf helper if needed. Do not trust an upstream-spoofable header. A newtests/server/server-combo-local-codex-cooldown.test.tsshould 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.docs(compaction): point compaction combos at cooldown recovery (#8537)
lidge-jun commentedon Nov 11, 2026
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 madecombo_unavailablename the earliest recovery on the Responses and Claude Messages listeners. #8537 documents the opt-incooldownReproberecovery for a dedicated compaction combo in thecompactionRoutingreference. Client or UI behavior while a compaction stays pending was not reproduced here; please open a new issue with a reproduction if it persists.