Skip to content

opencode-route-proxy: known-100% seating gate — exclude legs whose binding quota window is known exhausted until reset (#4370c) #5295

Closed

Description

@dezren39

opencode-route-proxy: known-100% seating gate — exclude legs whose binding quota window is known exhausted until reset (#4370 acceptance (c))

Implementation slice scoped by triage task 8950 (lane W, 2026-11-04) extending #3325 leg-shedding to the #4370 death classes. Findings and full evidence are on #3325 (task 8950 comment) and #4370.

Problem (verified at main, blob 70f01618, bin/opencode-route-proxy.mjs, 1095 lines)

Scope

  • Seating-time gate in bin/opencode-route-proxy.mjs: a (provider, model) pair whose binding quota window is known exhausted (ledger quota detail carrying a future reset, or an equivalent known-100% record the proxy already stores) is EXCLUDED from candidates until that reset — the credential-less exclusion pattern (opencode-route-proxy: opendesign leaves sit in pools but the provider's credential is inactive — walks burn attempts and surface a misleading auth error #3228).
  • Fail-safe: if exclusion would empty the route, keep current demoted order rather than hard-failing; record the gate decision in existing diagnostics.
  • Tests with the pinned-now clock (OPENCODE_ROUTE_PROXY_NOW_MS): known-100% pair excluded while a live pair exists; pair returns after reset; all-exhausted route still walks in demoted order.

Out of scope: external quota-service reads at request time, demotion threshold changes, transport timeouts (companion slice), in-stream shedding (task 8932).

Acceptance criteria

Refs: #4370 (acceptance (c)), #3325, task 8950.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    priority/highImportant and time-sensitive
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    on Nov 4, 2026
  2. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up → PR opened (task 9239)

    Implemented: knownExhaustedPairs + applyKnownExhaustedGate in bin/opencode-route-proxy.mjs — a pair whose latest quota-bearing ledger failure carries a future reset (Retry-After-derived or absolute) and no later success is excluded from candidates after demotion; fail-safe keeps the demoted order when exclusion would empty the route; decisions logged to the proxy's stderr diagnostics; clock via nowMs() so OPENCODE_ROUTE_PROXY_NOW_MS pins it.

    Verified on the laptop: node --test bin/opencode-route-proxy.test.mjs — 31/31 pass, including 4 new pinned-clock tests (exclusion with ledger extract, return after reset, all-exhausted bypass, success-clears-gate). This issue closes via the PR's Fixes #5295 on merge.

  3. added 3 commits that reference this issue on Nov 4, 2026
  4. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done (task 9239)

    Delivered: the known-100% seating gate in bin/opencode-route-proxy.mjs (#4370 acceptance (c)): pairs whose latest quota-bearing ledger failure carries a future reset and no later success are excluded at seating time; fail-safe keeps the demoted order when no credentialed candidate survives; decisions on the proxy's stderr diagnostics; clock via nowMs().

    Verification: node --test bin/opencode-route-proxy.test.mjs — 34/34 on the laptop, including 7 new pinned-clock gate tests. Codex review: three rounds — credential-aware fallback (P2), receipt-anchored Retry-After (P2), completion-time ordering (P2) — all fixed with regression tests and replied on-thread; final round completed with no findings.

    Claim labels cleared with this note.

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

    kind/bugSomething isn't working (prefixed form of the classic bug label)priority/highImportant and time-sensitivetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions