Skip to content

[Bug]: preflight fallback candidates for context-window and input-modality compatibility #1524

Closed

Description

@ideabib

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:

  1. Context window
    • the current conversation/request no longer fits the fallback model's effective context capacity;
  2. 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

  1. added
    bug
    on Aug 12, 2026
  2. added
    account-pool
    proxy
    on Aug 12, 2026
  3. ideabib commented on Aug 12, 2026

    @ideabib
    ContributorAuthor

    This should stay open as a broader routing-policy issue.

    Scope clarification (not a duplicate of #88)

    Related prior work:

    Why this issue (#1524) is still needed:

    Proposed acceptance slices for #1524

    1. Capability preflight before fallback

      • Evaluate candidate routes against request requirements (input modalities, effective context headroom, tool/reasoning continuity constraints).
      • Skip incompatible candidates before attempting upstream calls.
    2. Deterministic fallback precedence

      • Define and document the order between manual selection, policy routing, failure retry, cooldown, and fallback.
    3. Graceful degradation contract

      • If modality mismatch occurs, follow explicit policy:
        • preserve modality when possible,
        • transform via sidecar when allowed,
        • otherwise fail-fast with actionable reason.
      • Avoid silent dead-ends.
    4. Observability

      • Log/emit route-switch reasons and candidate rejection causes (e.g., incompatible_modality, insufficient_context_headroom, rate_limited, cooldown_active).
    5. UX/docs parity

      • Surface effective behavior in dashboard/CLI/docs so users understand why a route changed and what constraints applied.

    Related reliability context

  4. Ingwannu commented on Aug 12, 2026

    @Ingwannu
    Owner

    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.

  5. changed the title [-]Context-window + modality-aware fallback routing (avoid image-incompatible failover dead-ends)[/-] [+][Bug]: preflight fallback candidates for context-window and input-modality compatibility[/+] on Aug 12, 2026
  6. added
    catalog
    on Aug 15, 2026
  7. lidge-jun commented on Aug 16, 2026

    @lidge-jun
    Owner
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-poolbugcatalogproxy

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions