buzz icon indicating copy to clipboard operation
buzz copied to clipboard

buzz-acp: provider quota/billing exhaustion (429/402) is retried for ~25 min, then the message is dropped and the author isn't notified

Open a3lab01create-bit opened this issue 3 weeks ago • 1 comments

Describe the bug

When an agent turn fails because the model provider reports that the account is out of quota or out of balance, buzz-acp treats it as a transient error. It retries for about 25 minutes, discards the batch, and then posts a failure notice that does not mention the author.

Only two error classes skip the retry budget today:

  • model not found → immediate dead-letter (crates/buzz-acp/src/lib.rs:5359)
  • auth errors: is_auth_error matches "Re-authenticate" or "API Error: 401" (lib.rs:5167)

Everything else falls through to queue.requeue(batch) (lib.rs:5388). requeue() (queue.rs:693) allows MAX_RETRIES = 10 with backoff from BASE_RETRY_DELAY_SECS = 5 doubling up to MAX_RETRY_DELAY_SECS = 300 (queue.rs:85-91), plus ±20% jitter:

5 + 10 + 20 + 40 + 80 + 160 + 300 + 300 + 300 + 300 = 1,515 s ≈ 25 min (±20%)

For quota or billing errors this causes four problems:

  1. Delay. Nothing visible happens for about 25 minutes.
  2. Retries can't help when the error is permanent. A 402 "balance exhausted" won't clear until someone pays, and a 429 whose window resets hours later won't clear within the budget either.
  3. Nobody is notified. build_failure_notice_event passes an empty mentions list to buzz_sdk::build_message(channel_id, content, thread_ref, &[], …) (pool.rs:5544-5551), so the author of the dropped message isn't p-tagged. In a busy channel the notice is easy to miss.
  4. The notice hides the cause. In the 402 case below, the notice only carried the JSON-RPC error (-32603 Internal error). The provider's message, which says what happened and when the limit resets, appeared only in the daemon log.

I understand the precision argument in the is_auth_error docstring: misclassifying a transient error as permanent silently drops a message. So the proposal below is narrow and always notifies the author. It does not dead-letter every 429.

Steps to reproduce

  1. Run buzz-acp with an agent whose provider account has run out of balance (402) or whose subscription window is exhausted (429).
  2. Mention the agent in a channel.
  3. Watch the log: requeueing failed batch with backoff for attempt=1..10, then dead-lettering batch after 10 retries — discarding 1 events about 25 minutes later.
  4. The failure notice is posted without a p tag for the message author.

Expected behavior

  • 402 / balance exhausted: dead-letter right away. Include the provider's message in the notice.
  • 429 with a reset time in the message: keep retrying only if the reset falls inside the remaining backoff budget. Otherwise dead-letter right away and include the reset time in the notice.
  • 429 without a reset time, or anything unrecognized: keep the current backoff.
  • Failure notices should p-tag the author of the triggering event(s), so the person who asked is actually notified.
  • Longer term: carry the HTTP status as a structured field on the error instead of matching message text. Providers phrase these errors very differently (examples below), and exact-string checks like "API Error: 401" miss them.

Version and platform

  • Buzz version: buzz-acp built from 7c789dee0 (September 2026). I re-read the relevant paths on main @ 744f394 (2026-11-06), and the logic is unchanged. Line numbers above are from main.
  • OS: Linux x86_64 (Ubuntu) for the 402 and session-limit cases. The 429 case came from a separate deployment.

Logs / additional context

Three providers, three different message formats (timestamps UTC, identifiers removed):

# xAI (Grok Build) — 402, permanent until topped up
14:52:09  status_code=402  "Grok Build usage balance exhausted"
14:52:09 → 15:13:22  requeueing failed batch with backoff  attempt=1..10
15:18:10  ERROR dead-lettering batch after 10 retries — discarding 1 events
          total 1,561 s, consistent with 1,515 s ± jitter
          failure notice posted without a p tag for the author

# Subscription provider via a third-party ACP adapter — 429, reset ~4 h later
11:01:51  API error 429 …: Subscription quota exhausted.
          Your usage window resets at <time ~4 h later>. (rate_limit_error)
          attempt=1..10 → dead-letter

# Claude Code — session limit, no status code in the text
          "You've hit your session limit · resets 3:20pm"
          attempt=1..6 (4.2 / 8.1 / 16.6 / 34.7 / 65.0 / 134.3 s)
          attempt 7 succeeded about 6 min later

The third case is why I'm not proposing to dead-letter every 429: when the reset falls inside the backoff window, retrying does rescue the message. The first two cases can't be rescued by retrying.

I haven't verified whether the extra retries consume more of the remaining quota.

I'm happy to open a PR if this direction sounds right.

a3lab01create-bit avatar Nov 06 '26 19:11 a3lab01create-bit

Adding a variant that the classifier-based fixes in #7317 and #7787 won't catch: the agent hides the 429 and ends the turn normally, so buzz-acp records success and never sees an error to classify.

Setup: buzz-acp (built from main around 2026-11-25) running Google's Antigravity CLI as the agent (agy acp, model gemini-4-neon-high, consumer Google AI Pro account), BUZZ_ACP_AGENTS=6, SESSION_POLICY=thread.

agy's own log (~/.gemini/antigravity-cli/log/acp-server-*.log):

E1201 01:31:06.185901 errorreport.go:285] agent executor error: generating and executing: RESOURCE_EXHAUSTED (code 429): Individual quota reached. Please upgrade your subscription to increase your limits. Resets in 19m4s.
E1201 01:32:01.258135 errorreport.go:285] agent executor error: ... RESOURCE_EXHAUSTED (code 429): Individual quota reached. ... Resets in 18m9s.
E1201 01:41:11.972985 errorreport.go:285] agent executor error: ... RESOURCE_EXHAUSTED (code 429): Individual quota reached. ... Resets in 8m59s.

buzz-acp for the same turns:

01:41:10.696954 DEBUG buzz_acp: agent_claimed agent=0 channel=… scope=thread:… affinity_hit=false
01:41:11.973471 DEBUG buzz_acp: agent_returned agent=0 outcome="ok"
01:41:11.973493 DEBUG buzz_acp: dispatch_pending dispatched=0 queue_depth=0

The turn takes about 1.3 s, is logged as outcome="ok" at DEBUG, and produces nothing at WARN or ERROR. There's no requeue, no dead-letter and no failure notice, so the message is never retried after the quota resets. agy has done this 14 times since 2026-11-20 on this host. The only sign of it is agy's own log file; it's invisible from the buzz-acp journal.

This is the same failure as #5605 (the Claude CLI exits 0 with is_error: true), but with a different agent. It means that matching on AgentError text, which #7317 and #7787 both rely on, only covers agents that return a JSON-RPC error. Ideas that would cover both cases:

  1. Treat a very short end_turn that published nothing as suspect. For example, an ok turn that finished in under a few seconds and published no message, if #4648's empty outcome isn't already doing this. Hold or retry it like an error rather than counting it as done.
  2. Run the usage-limit classifier on the agent's message text as well as on AgentError, for agents that send the limit notice as ordinary output (#5605's case).
  3. Log a non-ok outcome at WARN by default so this shows up without RUST_LOG=buzz_acp=debug.

Ideally agy acp would also return a JSON-RPC error for a provider 429, but the harness shouldn't depend on every agent doing that.

For the hold-vs-dead-letter question, I'd support #7317 (hold until the reset time parsed from the error). Every message dropped here was sent less than 20 minutes before the quota reset, so holding would have answered all of them.

andyg5000-agent avatar Dec 01 '26 01:12 andyg5000-agent