Repository navigation
Description
Client or integration
Codex App / CLI
Area
Proxy and routing / fallback selection
Scope
This issue now tracks one focused routing defect:
Before retrying a request on a fallback route, OpenCodex should reject candidates that cannot accept the request's required context size or input modalities.
The broader UX problem of automatic/manual context compaction, model switching guidance, and general long-context workflow automation is out of scope here and should be tracked separately if needed.
Problem
A fallback candidate can be healthy from a quota/availability perspective but still be incompatible with the request.
Two important incompatibility classes are:
- Context window
- the current conversation/request no longer fits the fallback model's effective context capacity;
- Input modality
- the request contains images or other content that the fallback model/route cannot accept natively and for which no compatible transformation path is available.
Retrying such a candidate creates a predictable second failure instead of useful failover.
Example
active route
high-context + image-capable model
↓
429 / quota exhaustion
↓
fallback candidate
smaller context and/or text-only
↓
current behavior: retry anyway -> incompatible request / dead end
The desired behavior is:
fallback candidates
↓
preflight effective request requirements
↓
skip incompatible candidates
↓
try next eligible compatible route
Capability sources
Preflight must use authoritative or explicitly configured capability information.
For built-in providers/models, use the same effective catalog/runtime capability decision already used elsewhere.
For custom providers, unknown capability must remain unknown. Do not infer vision support, context capacity, or other compatibility solely from a model name or vendor lineage.
Where a safe transformation exists, such as an explicitly supported vision sidecar path, the preflight may account for that effective route behavior. It must not silently drop images or truncate context simply to make a fallback fit.
Required behavior
- Evaluate compatibility only after the actual fallback model/provider candidate is known.
- Skip a candidate whose effective context window is smaller than the request requires.
- Skip a candidate that cannot accept required input modalities and has no safe configured transformation path.
- Preserve unknown capability as unknown rather than manufacturing certainty.
- Continue to the next eligible candidate when one is incompatible.
- If no compatible candidate exists, fail with a clear bounded diagnostic instead of repeatedly trying known-incompatible routes.
- Do not mutate the user's conversation history or silently discard content during preflight.
- Preserve existing account health, quota, cooldown, affinity, and priority rules. Compatibility is an additional eligibility gate, not a replacement routing engine.
Diagnostics
A fallback decision should be explainable without logging request payloads.
Useful bounded reasons include:
skipped: context_window_too_small
skipped: image_input_unsupported
skipped: modality_unknown
selected: compatible_fallback
Exact enum names may follow repository conventions.
Acceptance criteria
- A fallback candidate with insufficient effective context capacity is skipped before dispatch.
- A text-only candidate is skipped when the request requires image input and no safe transformation applies.
- A compatible later candidate can still be selected and used.
- Unknown custom-provider capability is handled conservatively.
- No image content or conversation context is silently removed to force compatibility.
- Existing quota/health/affinity selection semantics remain intact.
- Regression tests cover mixed context windows, image-to-text-only failover, a compatible later candidate, unknown capability, and no-compatible-candidate behavior.
Out of scope
- automatic conversation compaction policy;
- generic model-switching UX;
- prompting the user to drop images;
- inventing context-window metadata for unknown custom models;
- changing provider quota/failover policy beyond the compatibility eligibility gate.
Activity
ideabib commentedon Aug 12, 2026
This should stay open as a broader routing-policy issue.
Scope clarification (not a duplicate of #88)
Related prior work:
deepseek/*) using the vision sidecar ondev(commit755fac5), so image-bearing requests no longer fail immediately in that path.Why this issue (#1524) is still needed:
Proposed acceptance slices for #1524
Capability preflight before fallback
Deterministic fallback precedence
Graceful degradation contract
Observability
incompatible_modality,insufficient_context_headroom,rate_limited,cooldown_active).UX/docs parity
Related reliability context
Ingwannu commentedon Aug 12, 2026
Agreed that this is broader than #88 and should remain open as a routing-policy enhancement, not a narrow provider bug. The acceptance slices in the clarification are the right direction.\n\nThe conservative implementation order is: (1) define a shared route-capability record for effective input modalities and context headroom, (2) use it only to reject incompatible fallback candidates before dispatch, (3) emit a structured rejection/switch reason, and only then (4) consider automatic compaction or modality transformation. Manual selection must remain authoritative, and dropping image content must never happen silently.\n\nThis should not be fixed by adding provider-specific retry branches. It needs one policy boundary shared by cooldown, fallback, combos, and sub-agent routing, with tests for precedence and observability. Keeping the bug label for the reported dead-end is reasonable, but the implementation is architectural and should be split into reviewable slices.
[-]Context-window + modality-aware fallback routing (avoid image-incompatible failover dead-ends)[/-][+][Bug]: preflight fallback candidates for context-window and input-modality compatibility[/+]fix(routing): let fallback skip a candidate the request cannot fit
fix(combos): let a local input-admission refusal actually hop the fal…
fix(errors): preserve the local admission-refusal code so the hop rul…
docs(devlog): record why the first #1524 fix did not work, and state …
docs(devlog): record the Wave 3/4 second pass, audit corrections and …
lidge-jun commentedon Aug 16, 2026
docs(devlog): record the Wave 3/4 final outcome and the review-bindin…
fix(routing): let fallback skip a candidate the request cannot fit
docs(devlog): record the Wave 3/4 second pass, audit corrections and …
fix(combos): let a local input-admission refusal actually hop the fal…
fix(errors): preserve the local admission-refusal code so the hop rul…
docs(devlog): record why the first lidge-jun#1524 fix did not work, a…
docs(devlog): record the Wave 3/4 final outcome and the review-bindin…