GeezerVison is showing github.com — ensure(core+openchamber): repeated errors of ANY class remove a model from rotation for escalating time, or until its expected resolution · Issue #1014 · developing-today-forks/opencode
ensure(core+openchamber): repeated errors of ANY class remove a model from rotation for escalating time, or until its expected resolution #1014Labels effort/lLarge: multi-day or open-ended; expect staged check-insexpediteImportant - do this very soon, before anything not expeditedkind/enhancementNew feature or requestmeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/highImportant and time-sensitivequeue/parkedQueue task is parked (waiting on CI, time, or an event)status/parkedDeliberately paused with a recorded resume conditionwork/assignedAn agent holds this item via the queue (claimed task) DescriptionDrew's directive (2026-10-30): ensure that OpenCode — and OpenChamber where it surfaces routes/models — removes a model/target from rotation when it repeatedly returns errors, for an increasing amount of time per recurrence, or until the time the error is expected to be resolved when that is known.
Error classes in scope (all of them)
- Rate limit (429, with or without Retry-After)
- Billing / funds (402, insufficient credits, payment-required class)
- Quota exhaustion (usage-limit errors naming a reset time)
- Auth/attestation failures
- Upstream 5xx and timeouts / first-token failures
- Any other repeated provider error class
Required behavior
- Repeated errors of any class take the model/target out of rotation — not retried on a fixed short interval forever.
- The removal duration ESCALATES with recurrence (increasing backoff), capped sensibly.
- When the error carries an expected resolution time (quota reset, Retry-After), the removal lasts until that time instead — and the target is restored automatically when it passes (or when a fresh quota read shows headroom).
- Restoration is automatic and probed, not permanent: a recovered model re-enters rotation without operator action.
- The behavior is consistent across both surfaces: the OpenCode router (packages/core model-route) and any OpenChamber-side model/route handling, so a model removed in one is not immediately re-offered by the other.
Existing partial coverage to verify against (do not duplicate blindly)
Acceptance criteria
- An audit table (in the PR or a linked comment) listing each error class above × where its removal/escalation/reset behavior lives, with the gaps found.
- Every gap closed: billing errors and non-quota repeated errors escalate like quota/rate-limit ones; openchamber surface checked and aligned.
- Tests demonstrating: repeated 402s remove the target with escalating cooldown; a quota error naming a reset restores the target at the reset; a recovered target re-enters rotation.
Activitydezren39 commented on Oct 30, 2026 Triage evidence — issue-sweep-rotating (feeder), 2026-10-30
Verified fresh against current main d2af8df514 (local clone at that exact SHA, code reading only). This issue is not already covered — the audit-shaped remainder below is real:
Already in place in the OpenCode router (partial coverage, confirmed by reading):
Gaps the audit still has to close (found this run):
- Text-only billing/funds errors that are neither a structured 402/QUOTA_CODE nor a match for the exhaustion-text regex at
step.ts:440 (insufficient credits|quota exhausted|usage limit exceeded|reached your .* limit) get only the ordinary failure bench — no quota-length hold, no reset-aware gate. Billing coverage is therefore classification-dependent, not class-wide.
- Proactive known-full:
observeCredentialQuota (model-route.ts:495) has no production caller (see router: auto-disable providers at 100% quota until a fresh read shows headroom (cline-pass, commandcode, go) #984 triage, comment 6534885631), so a target known-full from regular reads is not removed before its first failure of a session, for any error class.
- OpenChamber surface (cross-repo set remainder): a grep of the local openchamber clone found no consumption of the router's gate/cooldown state (no
credentialQuotaBlocked / quota-gated equivalent; only UI routing-pool fields). Whether OpenChamber re-offers a model the router has benched is unchecked — this is the set remainder owed in developing-today/openchamber, to be triaged from this origin issue by a later feeder run in that repo (recorded as a SET-REMAINDER entry in the opencode backlog; no per-repo issue filed).
Done looks like: the acceptance audit table (error class × removal/escalation/reset location) posted on this issue, every gap in it closed or explicitly dispositioned, and the three acceptance tests (repeated 402s escalate; quota error naming a reset restores at the reset; recovered target re-enters rotation).
Enqueueing as a triage packet to repo-health-opencode-pilot; the queue lane owns the audit and any implementation routing.
dezren39 commented on Oct 30, 2026 agent-note:v1
state: queued
Agent: issue-sweep-rotating (triage feeder)
Session/ID: issue-sweep-rotating run 2026-10-30 17:24 CDT
Found via: feeder triage (evidence comment 6534944157)
Task: Enqueued triage packet to repo-health-opencode-pilot as task 4019 (dedupe repo-health:v1:triage:developing-today/opencode:issue:1014; packet hidden_files/packet-opencode-1014-triage.json)
Expectation: queue lane produces the error-class audit table and routes each gap. Cross-repo SET-REMAINDER: developing-today/openchamber surface alignment is owed and is triaged from this origin issue — no per-repo issue filed. Feeder took no implementation action.
dezren39 commented on Oct 30, 2026 agent-note:v1
state: in-progress
Agent: repo-worker-opencode (OpenChamber scheduled lane)
Session/ID: ses_e5e70f5617bffeD2NizFCNQRVE
Found via: repo-health-opencode-pilot task 4019
Task: Triage issue #1014: all-error-class rotation audit — removal/escalation gaps by class
Expectation: Produce the acceptance audit table, disposition or route each gap, verify acceptance tests / behaviour, align cross-repo set remainder with developing-today/openchamber.
dezren39 commented on Oct 30, 2026 Audit table — all-error-class rotation (queue task 4019, main be8dd99965)
Verified fresh against be8dd99965 (fast-forwarded from feeder d2af8df514; only oauth/model-list changes in between, nothing in the router path). Prior coverage confirmed: #823 closed (escalating cooldown), #870 closed (credential threading), PR #991 merged 2026-10-30 (reactive quota gate), #984 still OPEN (proactive auto-disable).
| Error class |
Removal (out of rotation) |
Escalation |
Reset / re-admit |
Verdict |
| 429 rate-limit, Retry-After stated |
ModelRoute.failed via step.ts:550 with failureHint (step.ts:135); bench() (model-route.ts:337) sets cooldownUntil |
retryAfterMs believed as-is, never multiplied (model-route.ts:350); without it, doubles per consecutiveFailures, cap 1 day (model-route.ts:352, MAX_COOLDOWN_MS) |
Header hold via observeRateLimit/limitedUntil plus bench expiry via recover() (model-route.ts:269); success in completed() (model-route.ts:586) resets count and bench |
COVERED |
| 429 rate-limit, no Retry-After |
Same bench path |
Doubles from base cooldownMs, cap 1 day |
Bench expiry + completed() reset |
COVERED |
402 / billing, structured (HTTP 402 or QUOTA_CODES: insufficient_quota, billing_error, creditlimitexceeded, …) |
provider-error.ts:261 → QuotaExceeded → quota:true hint → long first bench (quotaCooldownMs) + observeQuotaFailure gate (step.ts:441, model-route.ts:532) |
Long-base doubling, cap 1 day; gate holds until stated reset (capped 30d) or 30-min fallback (model-route.ts:514) |
Gate re-derives per check; reset passing re-admits (credentialQuotaBlocked, model-route.ts:569); fresher below-limit snapshot re-admits early; success resets escalation |
COVERED |
| 402 / billing, text-only (no 402 status, no QUOTA_CODE; e.g. 400 + "insufficient credits") |
provider-error.ts:302 → InvalidRequest (non-retryable, isRetryable:false) → post-stream routeFailure false → no ModelRoute.failed bench on the post-stream path; mid-stream pre-output errors still bench via step.ts:281 |
When benched (mid-stream), ordinary-base doubling — but post-stream text billing is often never benched at all |
No observeQuotaFailure unless the step.ts:440 exhaustion regex matches (insufficient credits|quota exhausted|usage limit exceeded|reached your .* limit); outside those 4 phrases, no reset-aware gate |
GAP → routed (see disposition D1 below) |
| Quota exhaustion naming a reset |
Same as structured-402 path + retryAfterMs from failureHint believed |
Retry-after believed; otherwise long-base doubling |
observeQuotaFailure until resetAt (step.ts:448); re-admit at reset or on fresher healthy snapshot |
COVERED |
Auth (401/403, AUTH_CODES, org-disabled) |
auth:true hint (step.ts:151) → long first bench |
Long-base doubling, cap 1 day |
No reset (correct: cannot self-heal); success resets; routeFailure includes Auth so it benches post-stream |
COVERED |
Upstream 5xx / ProviderInternal |
Retryable → benches post-stream |
Ordinary-base doubling, cap 1 day |
Bench expiry + success reset; retryAfterMs believed when stated |
COVERED |
| Timeout / first-token stall / slow |
Transport/Timeout (non-retryable, no bench via routeFailure) BUT first-token timeout synthesizes a Timeout error pre-output and the hedge/escalation path applies; slow() (model-route.ts:405) cools repeatedly-slow targets; giveUps/escalates (model-route.ts:454) races next target |
Slow bench cooldownMs; failure doubling where applied |
Expiry + success reset |
COVERED (slow/hedge path, not a quota-style gate — correctly, no known reset exists) |
Any other repeated, retryable (UnknownProvider, Transport w/o response) |
Retryable → ModelRoute.failed post-stream |
Ordinary-base doubling, cap 1 day; count survives recover(), resets only on success (model-route.ts:335) |
Expiry + success reset |
COVERED |
Any other repeated, deterministic (InvalidRequest non-overflow, ContentPolicy, NoRoute, UnsupportedOperation) |
Intentionally NOT benched post-stream (request would fail on any model) |
n/a (correct) |
n/a |
COVERED BY DESIGN — benching every model for a bad request would be wrong |
| Network-suspect (3+ providers fail in 30s) |
Benches cleared, not extended (model-route.ts:381) |
n/a (correct: local outage, not provider fault) |
Immediate |
COVERED BY DESIGN |
| Proactive known-full (no failure yet this session) |
observeCredentialQuota (model-route.ts:495) + credentialQuotaBlocked gate exist and are tested |
n/a |
Reset passing or fresher healthy snapshot re-admits |
GAP → owned by #984 (no production caller; packet 4017 owns the wiring; not re-implemented here per scope) |
| OpenChamber surface |
pool-health.js is explicitly read-only/advisory ("never moves a session or changes a weight by itself"); route-wait.js only reads OpenCode route_health cooldown-start history for wait estimates; no credentialQuotaBlocked/gate consumption found |
— |
— |
NO CONFLICT: OpenChamber never re-offers a benched model because selection lives in the OpenCode router. SET-REMAINDER owed in developing-today/openchamber: surface the gate/quota-block state in pool health (read-only display), triaged from this origin issue — no per-repo issue filed per packet scope. |
Dispositions
- D1 (routed, small follow-up): widen the text path so billing-text failures feed the quota gate and the bench. Concretely: extend the
step.ts:440 exhaustion regex (and consider a billing-text arm in provider-error.ts QUOTA_TEXT/400-path, e.g. insufficient credits|billing|payment required|credit limit|out of credits) so text-only billing classifies quota-side: long first bench + observeQuotaFailure gate instead of sometimes-no-bench. Suggested new queue task; not implemented in this triage (no code changed here).
- D2 (owned elsewhere): proactive
observeCredentialQuota wiring → router: auto-disable providers at 100% quota until a fresh read shows headroom (cline-pass, commandcode, go) #984 / packet 4017.
- D3 (cross-repo remainder): OpenChamber pool-health display of benched/gated targets → owed in developing-today/openchamber, triaged from this issue, no per-repo issue filed.
- Everything else: already covered. No code change in this task by design (triage scope).
Acceptance tests pinned (all exist today, no new tests written here)
- "Repeated 402s remove the target with escalating cooldown" →
packages/core/test/model-route.test.ts:271 ("an exhausted quota outlasts an ordinary failure", quota=true is the 402 path) + :280 ("repeated failures double the bench, count survives expiry") + :304 (auth/long-base escalation shape). A literal 402-status test would live in packages/ai classification + this bench pair; D1 follow-up should add it.
- "A quota error naming a reset restores the target at the reset" →
packages/core/test/model-route-credential.test.ts:211 ("credentialed exhaustion gates only that credential until the stated reset") + :220 (fallback hold + 30d cap) + :229 (credential-less provider skip until reset).
- "A recovered target re-enters rotation" →
model-route.test.ts:294 ("success resets escalation") + model-route-credential.test.ts:160 ("fresher good read re-admits before reset") + :145 ("blocked until reset, then re-admitted with health record"); expiry path via recover() (model-route.ts:269) covered by :280 (cooldownUntil 0 after expiry).
Worktree ~/git/fleet/4019, branch queue/4019-1014-error-class-audit created, no commits (triage-only, read + gh).
dezren39 commented on Nov 2, 2026 dezren39 commented on Nov 2, 2026 dezren39 commented on Nov 2, 2026 PR3 merged: PR #1384 (merge commit f7b4c02, 2026-11-02T12:45:42Z) — pool-shaped quota pull-out + any-error-class escalating bench.
Independent verification before merge (fresh worktree at the PR head 4794119, deps installed from scratch — not the worker's own run):
- model-route.test.ts: 98/98 pass (includes the new pool pull-out, reset-restoration, and re-entry tests)
- session-step.test.ts + model-resolver.test.ts: 105/105 pass (includes the new repeated-timeout and repeated-402 escalating bench tests)
- model-route-credential + session-runner-model + model-routes-expand: 98/98 pass
bun run typecheck in packages/core: clean (exit 0)
- Diff reviewed by hand against the PR3 scope in the gap analysis: pool verdict is derived from live leaf quota state (self-restoring at stated resets; balance-held pools re-admit only on a fresh balance increase), pool-exhausted leaves are hard-excluded from the all-full last resort, and step.ts health accounting now reaches
ModelRoute.failed for terminal non-retryable classes while the current-request failover gate is unchanged.
#1014 stays open: the runner-policy packet (#1379, task 6191, queued) and the CodeRabbit follow-ups (#1380, task 6192, parked) remain, per the PR3 body. dezren39 commented on Nov 2, 2026 Reopening: #1014 auto-closed 4 seconds after the PR #1384 merge (closed 2026-11-02T12:45:46Z, reason COMPLETED) — the PR body and the task-6188 handoff both record explicitly that PR3 does not close this issue. The runner-policy packet (#1379) and the CodeRabbit follow-ups (#1380) are still outstanding, so #1014 stays open until they land.
MetadataMetadataeffort/lLarge: multi-day or open-ended; expect staged check-insexpediteImportant - do this very soon, before anything not expeditedkind/enhancementNew feature or requestmeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/highImportant and time-sensitivequeue/parkedQueue task is parked (waiting on CI, time, or an event)status/parkedDeliberately paused with a recorded resume conditionwork/assignedAn agent holds this item via the queue (claimed task) DevelopmentNo branches or pull requestsIssue actions
|