fix(session): a follow-up queued behind a failed turn starts, or fails typed under a usage hold

CO
20h ago
+350-77

Fixes #6868.

A follow-up queued while a turn runs never started when that turn ended in a provider error. The session went idle with the follow-up parked, and an RPC or relay sender waiting on it hung until the session closed. This implements the issue's ruled behaviour:

  • After retries and fallback settle on a provider error, queued input starts its own turn. It is new input, not a retry of the failed request.
  • Under a rate-limit or spent-account hold (the senpi#3131 guard), the queued prompt fails with a typed account_usage_limit refusal naming the hold. It leaves the queue through the existing pending-input journal, and the waiting sender resolves with it.
  • A user abort keeps today's behaviour: queued input waits. A local (journal or file) failure still never continues the run.
  • omo#14428's backoff still applies to peer deliveries after a transient rate limit or overload with no hold.
  • The #4036 comments now state the new rule. The #4036 and omo#14428 regressions that pinned "a provider error parks the queue" now park through a user abort, citing this ruling.

Evidence (faux provider and harness, offline):

  • RED on origin/main b596b152: CI=1 vitest run --maxWorkers=1 test/suite/regressions/6868-queued-followup-after-error.test.ts gave 2 failed, 1 passed. The follow-up was never requested, and the held follow-up stayed queued at count 1. The user-abort control passed.
  • GREEN: 135/135 across 19 queue, hold, compaction-exemption, omo#14428, #4036 and RPC-queue files. The three source-mode RPC queued-input files passed 4/4. An independent rerun of the regression with the queue, #3131, omo#14428 and #4036 suites passed 78/78 across 7 files.

Format, lint, the source type check and the browser smoke check passed.


Summary by cubic

Fixes #6868. A follow-up queued behind a turn that ended in a provider error never started: the session went idle with the follow-up parked, and the sender waiting on it hung until session close. Queued input now starts its own turn after retries and fallback settle on a provider error, or fails with a typed account_usage_limit refusal when the provider is under a rate-limit or spent-account hold. A user abort still leaves queued input waiting.

Refusals and receipts

  • Refused input leaves the queue through the pending-input journal and surfaces as a refused RPC effect, so waiting senders resolve instead of hanging.
  • After a transient rate limit or overload without a hold, omo#14428's backoff still applies to peer deliveries.