GeezerVison is showing github.com — fix(routes): thread the credential dimension through restore, escalation, ranking, rate-limit holds and catalog headers (PR #854 follow-up) · Issue #870 · developing-today-forks/opencode
fix(routes): thread the credential dimension through restore, escalation, ranking, rate-limit holds and catalog headers (PR #854 follow-up) #870DescriptionFollow-up to PR #854 (credential failover, merged for #6). Five Codex P2 findings were unresolved at merge. Each is a place where a credential dimension was added locally but not threaded through a consumer, so the per-credential state exists yet some paths still read target-wide state.
All five are consistency/correctness edges of the new feature rather than regressions to previous behavior; they do not block the merge gate, but they should be closed before the credential dimension is relied on.
Findings
-
Restart replay benches the whole target — packages/core/src/model-route.ts:343. ModelRouteLog.restoreCooldownsFrom groups health records by provider/model only and ignores credential:<id> in the reason, so a credential-specific cooldown-start is restored as a target-wide cooldown. If credential A exhausts quota, failover moves to B, and the server restarts before A's cooldown expires, healthy B is excluded from normal routing.
Expect: preserve the credential dimension on restore; only the benched credential is excluded.
-
Adaptive escalation never sees credential failures — model-route.ts:381. For stored-credential targets the failure is recorded only in credentialHealth, while giveUps, steady, and escalates still read target health. Repeated provider failures leave the target "steady" indefinitely, so SessionStep.attempt never enables adaptive immediate hedging and the retry branch keeps granting the steady-target retry.
Expect: cooldown isolation stays, but the serving credential's failure history is visible to those consumers.
-
Quota demotion skipped in normal selection — model-route.ts:463. tracedWeightOf, nextTarget, keepsThrough call demoted(target) without a credential, so credential-qualified quota events are invisible. Once cooldown expires the exhausted active credential regains its original rank instead of staying demoted for the configured quota window.
Expect: thread the active credential through normal selection, not only credentialFallback candidates.
-
Rate-limit hold leaks across credentials — model-resolver.ts:631-634. captureRateLimit / the failure path call ModelRoute.observeRateLimit without a credential dimension and limits stays keyed by provider/model. A's 429 Retry-After survives the switch to B, and if B's success carries no rate-limit headers the hold is never replaced, so limitedUntil(target) keeps excluding B until A's reset.
Expect: scope holds to the serving credential.
-
Retried request mixes accounts — model-resolver.ts:631. On a switch between stored ChatGPT OAuth credentials for different accounts, source.headers still carries account A's chatgpt-account-id; the retry combines B's token with A's header and can fail authentication.
Expect: refresh account-specific catalog metadata (or re-derive headers) after activation, before re-issuing.
Acceptance
- Restart-restored cooldowns are per credential; a healthy alternate credential is still routable after restart.
- Credential failure history feeds adaptive escalation/hedging decisions.
- Credential-qualified quota demotion applies in ranking and stickiness, not only in fallback candidate selection.
- Rate-limit holds are per credential and clear for a credential that succeeds without limit headers.
- Account-scoped headers follow the activated credential on retry.
- New tests cover each case; existing model-route / model-resolver / session-runner suites pass.
Merged PR: #854 (head ee8bf2e12a). Source: Codex review comments on that PR. Activitydeveloping-today commented on Oct 29, 2026 dezren39 commented on Oct 29, 2026 Dependency note from queue task 3416 (lane A): this follow-up cannot be implemented yet — PR #854 is still OPEN (head ee8bf2e, branch queue/3290-6-credential-failover, CI queued), not merged as the issue text states. The credential-dimension code it threads through (credentialHealth, per-credential cooldown reasons in model-route.ts / model-resolver.ts) exists only on that branch; current main has none of it. PR #854 is owned by queue task 3290 via issue #6 (parked awaiting its CI; #6 also carries user/review). Task 3416 is parked and resumes once PR #854 merges to main: then implement the five findings against the merged code, in the files/tests named in the issue.
dezren39 commented on Oct 29, 2026 Dependency update: PR #854 merged 2026-10-29T18:13Z (merge commit 427f20399e, verified fresh), so this task is unblocked and ready to implement against current main. Task 3416 is parked ready-to-implement with the five findings itemised as the resume brief; it needs a full shift (medium risk, ~45-min timebox).
dezren39 commented on Oct 29, 2026 Implementation opened as PR #920 (branch queue/3416-870-credential-threading, commit 86b4f41): all five credential-threading findings addressed — per-credential restore in restoreCooldownsFrom/seedCooldowns/seedLimits, credential-aware giveUps/steady/escalates wired through the session runner, credential-qualified demotion in tracedWeightOf/nextTarget/keepsThrough via the resolver, per-credential rate-limit holds with per-credential clearing on headerless success, and chatgpt-account-id re-derived from the activated credential in credentialFallback. Local verification: model-route-credential+limits 34 pass, model-route-log 26 pass, model-resolver 66 pass, model-route* 195 pass, session-runner* 182 pass, core typecheck + oxlint clean. Awaiting CI on the PR.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|