Make sessions survive ZCode concurrency refusals
Problem
ZCode answers a second concurrent request on one account with
3008/3009/3010 (user concurrency limit exceeded). The gateway admitted up
to four requests per account, treated the refusal like a generic error, and
retried the same account immediately. A burst of real sessions therefore lost
requests even when the pool had free accounts.
Suspended accounts had a similar failure: a 405/3012 saying the account was
suspended for proxying parked only the requested model, so the banned account
stayed in rotation and returned 405 on every request. The dashboard hid all of
this behind an N err tooltip.
Changes
- Treat
3008/3009/3010as retryable capacity errors. - Admit one in-flight request per account and queue the rest
(acquire_wait_seconds, default 120s) instead of over-admitting. - After a refusal, hold the account with exponential backoff (10s doubling to
60s, cleared by the next success). State staysREADY; no cooldown, model
park, or error history. - Detect the account-suspension message and mark the account
DEADwith
death_reason=suspended, so it leaves rotation until an operator re-enables
it. - Accounts page: add an Issues metric and a Needs attention panel naming each
blocked account, its reason, and an Enable action for dead accounts. Show the
last error inline with its age, and show concurrency holds / cooldowns under
the state badge.
Tests
pytest -q: 1393 passed, 147 skipped.- New regressions cover queueing, hold escalation and clearing, affinity
skipping a held account, burst routing, and suspension removal. - Validated on a live gateway: 12/12 concurrent requests returned 200, 9/9
accounts ready, and a suspended account left rotation on the first upstream
405.
Summary by cubic
Fixes request loss when ZCode enforces per-account concurrency limits and removes suspended accounts from rotation instead of retrying them on every request.
Bug Fixes
- Treats
3008/3009/3010as retryable capacity errors and normalizes them to HTTP 429. - Limits each account to one in-flight request and queues the rest (default 120s wait) instead of over-admitting.
- After a refusal, benches the account with exponential backoff (10s doubling to 60s, cleared by success) without cooling, parking, or error history.
- Recognizes the account-suspension message and marks the account DEAD with reason
suspended; it stays out of rotation until an operator re-enables it.
New Features
- Accounts page: added an Issues metric and a Needs attention panel listing blocked accounts with reasons and an Enable action for dead ones.
- Shows the last error inline with its age and surfaces concurrency holds and cooldowns under the state badge.