Skip to content

fix(provider): retry bound accounts after transient 403/auth cooldowns - #2267

Open
singlerider wants to merge 1 commit into
1jehuang:masterfrom
singlerider:fix/bound-account-transient-403
Open

singlerider wants to merge 1 commit into
1jehuang:masterfrom
singlerider:fix/bound-account-transient-403

Conversation

@singlerider

@singlerider singlerider commented Nov 21, 2026 •

Copy link
Copy Markdown

Closes #2268

Problem

A single transient Anthropic 403 Forbidden (Request not allowed, e.g. from briefly routing through a blocked region over VPN) records a 5-minute runtime cooldown for the session's bound account. The bound-account pre-flight in MultiProvider then bails with <provider> (<label>) is unavailable: ... (runtime-error, Nm ago) on every later turn without contacting the API. Only a successful request clears the marker, so affected sessions stay wedged until the daemon restarts.

Repro

See #2268: VPN into a blocked region, get a 403, switch back. jcode never retries.

Expected vs actual

  • Expected: the next turn re-attempts and recovers once the 403 cause is gone.
  • Actual: every turn fails locally with no HTTP request until restart.

Fix

Only quota cooldowns short-circuit the bound-account pre-flight (reusing existing is_quota_failure). Auth, 403 and transport cooldowns fall through to a real attempt, which clears the marker on success or re-records it on failure.

Tradeoffs / edge cases

  • A persistent 403/401 now costs one real request per turn instead of zero. That request fails fast and still triggers the same failover/prompt path, so behavior seen by the user is the same apart from recovery.
  • Quota cooldowns and account_known_exhausted still skip the request as before.
  • Unbound (pool/auto) routing is unchanged.

Tests

  • New: bound_preflight_only_skips_requests_for_quota_cooldowns
  • cargo test -p jcode-base --lib provider::: 312 passed

@singlerider
singlerider marked this pull request as ready for review November 21, 2026 03:22
@greptile-apps

greptile-apps Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issues were found.

Summary

Bound accounts can retry after temporary auth, 403, and transport failures. Quota cooldowns and known account exhaustion still block requests.

  • Bound-account sessions retry after non-quota cooldowns.

The earlier weekly-limit finding is fixed. Its thread was manually resolved without an explanatory reply.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Bound account request] --> B{Quota cooldown or known exhaustion?}
  B -->|Yes| C[Existing reset or failover path]
  B -->|No| D[Attempt request]
  D -->|Success| E[Clear older cooldown]
  D -->|Failure| F[Existing error and failover path]
Loading

Reviews (2) · Last reviewed commit: "fix(provider): retry bound accounts afte..." · Reviewed by Greptile

A single transient Anthropic 403 ("Request not allowed") recorded a
5-minute runtime cooldown for the session's bound account. The bound
account pre-flight then bailed on every later turn with "is unavailable"
without contacting the API, so the cooldown was never cleared by a
successful request. Sessions stayed wedged until the daemon restarted.

Only quota cooldowns now short-circuit the bound-account pre-flight.
Auth, 403 and transport cooldowns fall through to a real attempt, which
clears the marker on success or re-records it on failure.
@singlerider
singlerider force-pushed the fix/bound-account-transient-403 branch from bd07586 to 7d2a866 Compare November 21, 2026 03:47
xenking added a commit to xenking/jcode that referenced this pull request Nov 22, 2026
Keep quota cooldowns as a preflight guard, but let a bound account prove recovery from transient auth or transport failures.

Upstream-PR: 1jehuang#2267

Co-authored-by: Shane Engelman <[email protected]>
xenking added a commit to xenking/jcode that referenced this pull request Nov 22, 2026
Upstream-PR: 1jehuang#1357
Upstream-PR-Commit: 1jehuang#1357 0da5e81
Upstream-PR: 1jehuang#1362
Upstream-PR-Commit: 1jehuang#1362 5962058
Upstream-PR: 1jehuang#1486
Upstream-PR-Commit: 1jehuang#1486 fadc624
Upstream-PR: 1jehuang#1733
Upstream-PR-Commit: 1jehuang#1733 01f3415
Upstream-PR: 1jehuang#1750
Upstream-PR-Commit: 1jehuang#1750 1ac0c82
Upstream-PR: 1jehuang#1822
Upstream-PR-Commit: 1jehuang#1822 73f85fc
Upstream-PR: 1jehuang#1912
Upstream-PR-Commit: 1jehuang#1912 36d7682
Upstream-PR: 1jehuang#1978
Upstream-PR-Commit: 1jehuang#1978 0f55643
Upstream-PR: 1jehuang#2007
Upstream-PR-Commit: 1jehuang#2007 638f87c
Upstream-PR: 1jehuang#2213
Upstream-PR-Commit: 1jehuang#2213 c5e1487
Upstream-PR: 1jehuang#2234
Upstream-PR-Commit: 1jehuang#2234 0d4d5d4
Upstream-PR: 1jehuang#2266
Upstream-PR-Commit: 1jehuang#2266 217ddc2
Upstream-PR: 1jehuang#2267
Upstream-PR-Commit: 1jehuang#2267 e98c40b
Vedaru pushed a commit to Vedaru/jcode that referenced this pull request Nov 24, 2026
A cached provider cooldown skipped every turn for its full TTL after any
failover-classified failure, including a 402 billing refusal. Only a
successful request clears the marker, and the marker blocks the very
request that would clear it, so a top-up (or a fixed key) looks ignored
for five minutes behind a stale "runtime-error, Nm ago" note.

Apply the rule from 1jehuang#2267 to the generic failover preflight as well:
only quota/plan exhaustion justifies skipping a request. Billing, auth
and transport failures reach the provider again and clear on success.
Vedaru pushed a commit to Vedaru/jcode that referenced this pull request Nov 24, 2026
A cached provider cooldown skipped every turn for its full TTL after any
failover-classified failure, including a 402 billing refusal. Only a
successful request clears the marker, and the marker blocks the very
request that would clear it, so a top-up (or a fixed key) looks ignored
for five minutes behind a stale "runtime-error, Nm ago" note.

Apply the rule from 1jehuang#2267 to the generic failover preflight as well:
only quota/plan exhaustion justifies skipping a request. Billing, auth
and transport failures reach the provider again and clear on success.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Transient Anthropic 403 wedges bound-account sessions until daemon restart

1 participant