Repository navigation
feat(desktop): retry overloaded turns and wait for the internet - #3491
Merged
Merged
Conversation
A turn a provider overload stopped is tried again after 30 s, 1 m, 2 m and 4 m, with up to a quarter added at random so an account's threads do not wake together, and never a fifth time; a credit or spend limit is never retried. A turn whose machine had no network waits for it instead of dying: the app asks the webview every 5 s, and at once on online or a wake, and sends "Please continue." once the connection has stayed up for 5 s, 30 s, 2 m and then 5 m on later retries, giving up after 6 h. Both show the queue's row over the composer with Send now and Cancel, and both survive a restart. The classifier for a lost network and the two schedules are pure modules with their own tests, and store tests send the resume turn once a wait is due.
…etry-overload-restart # Conflicts: # apps/desktop/src/state/store.ts
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.
What
Two more causes for a turn the user does not have to restart by hand, in the
same code path as the usage-limit wait (
state/limitResume.ts).overloaded_erroris tried again after a doubling backoff — 30 s, 1 m, 2 m,4 m — with up to a quarter of it added at random so an account's threads do
not wake together. Never a fifth time, and a credit or spend limit is never
retried. The classifier, the backoff and the attempt cap are pure
(
overloadStop,overloadDelay,nextWait).store.tsresumeInterruptedsends "Continue where you left off" to the threads a quit, an update or an
engine restart cut off. It is reused as it stands; nothing was duplicated.
(Claude Code "Can't reach the API server", Codex's dropped stream, Pi's
"fetch failed"; classified in
state/turnError.tsnetworkFailure, never onea provider answered) waits for the connection instead of dying. While any
thread waits the app asks the webview every 5 s, and at once on
onlineor awake, then sends "Please continue." once the connection has stayed up for
5 s, 30 s, 2 m and then 5 m on later retries, so flaky Wi-Fi cannot burn them.
After 6 h it gives up and says so. The schedule is pure (
state/internetWait.ts).Both waits show the same row over the composer, now with Send now and
Cancel, in the existing type and colours. Both hold queued messages, both
end when the thread moves to another harness or account or when the user sends
anything, and both survive an app restart. Settings › General's row is renamed
"Continue threads on their own", since it now covers all three causes.
Changelog
A turn a provider overload stopped retries itself with a doubling backoff, and a turn the network killed waits for the connection instead of failing for good.
Testing
bun run checkinapps/desktop: typecheck, lint, 2068 tests, build — all pass.and spend limits never retry), backoff and jitter bounds, the 4-attempt cap, a
stop that changes kind, the network classifier (positive per harness, negative
for 401/429/503/529, a limit and a spend limit), the stable-period escalation
(5 s, 30 s, 2 m, 5 m) and the 6 h cap.
sends the resume turn when it falls due; a credit limit creates no wait; a
network error waits, and sends "Please continue." only once the connection has
been up 5 s.
Closes #3388
Closes #3389