fix(cli): stop run from sleeping through an exhausted quota - #42340
Open
DaisukeYoda wants to merge 1 commit into
Open
fix(cli): stop run from sleeping through an exhausted quota#42340DaisukeYoda wants to merge 1 commit into
run from sleeping through an exhausted quota#42340DaisukeYoda wants to merge 1 commit into
Conversation
Quota errors are retryable, and the retry schedule honors the provider's retry-after, which for a monthly limit is days. While it sleeps, halt() never runs, so no session.error and no idle are published. The non-interactive loop breaks only on idle and ignores retry status, so it waits with no output and no exit. Handle retry status in that loop: print it, and exit non-zero when action.reason marks the limit as non-transient. Transient retries carry no action.reason and still wait and retry as before. The session is aborted first because the sleeping schedule otherwise keeps the process alive after the loop breaks. Retry timing is unchanged; honoring long retry-after values is deliberate (0a2d7af). Fixes anomalyco#40747
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #40747
Type of change
What does this PR do?
opencode runproduces no output and never returns when a model's quota is exhausted.It isn't wedged, it's sleeping. The quota error is classified as retryable, and
delay()honors the provider'sretry-after, which for a monthly limit is days. While the schedule sleepshalt()never runs, so nosession.errorand noidleare published, andloop()incli/cmd/run.tsbreaks only onidleand has no branch forretrystatus. The TUI is unaffected because it shows the retry in its footer; a headless run has nowhere to show it.I left the retry timing alone — honoring long
retry-aftervalues was deliberate in 0a2d7af, and waiting out a short rate limit is useful. Only the non-interactive loop changes:action.reasonisfree_tier_limit/account_rate_limit; transient retries (429/5xx) carry noaction.reasonand still wait and retry as beforeHow did you verify your code works?
New test in
test/cli/run/run-process.test.ts: the test provider returns a 429 carryingGoUsageLimitErrorwithretry-after: 345600, and the run must exit non-zero and mention the limit on stderr. On unmodifieddevit hangs until the harness kills it at 30 s; with this change it passes in ~2 s.Setting that header needed an optional
headersargument onhttpError()/llm.error()in the test harness —retry-afterdrives the delay and there was no way to set it before.bun test test/session/retry.test.ts test/cli/run/→ 250 pass, 5 skip, 0 fail.tsc --noEmit→ matches thedevbaseline (12 pre-existing errors inpackages/tui).Screenshots / recordings
Not a UI change.
Checklist