Files
sub2api/backend
William DrakeandClaude Opus 5.5 4ce6281fc0 fix(gateway): stop one bad request from cooling every account it touches
A gemini-3.8-flash request whose tools made the model end with
MALFORMED_FUNCTION_CALL produced an empty compat stream on every account.
The empty-stream error is retryable on the same account, so after three
retries the failover loop temp-unscheduled the account and moved on; the
same request then cooled the next account, and the next. One request took
three shared Antigravity accounts offline and every customer on those
groups got "No available accounts" until the cooldowns expired.

Two changes:

- The streaming processor records MALFORMED_FUNCTION_CALL. An empty compat
  stream that ended that way is marked RequestScopedTransient: still
  retried (model output varies), but it no longer cools the account. Once
  keepalive has committed the response, the SSE error says
  malformed_function_call instead of empty_stream.
- The failover loop cools at most one account per request. When the same
  retryable error follows a request to another account, the request is the
  likely cause; the loop still excludes and switches, and logs
  gateway.failover_temp_unschedule_skipped. An unhealthy account is still
  cooled by the next request that reaches it first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:37:21 -07:00
..
…