tlerbao (#5371): an Antigravity quota ran out, magpie rested the account
until the plan's reset hours away, and that horizon went to OpenCode as
Retry-After. OpenCode clamps one wait at 900s and asks the same model a
few times, so it sat ~45 minutes before its own fallback chain moved on.
RetryAfterCap (seconds, unset by default) bounds the Retry-After an
agent is told. Accounts rest exactly as long either way: restAfter and
the held try read the header before it leaves.
Changed from ggbdpq's patch:
- The cap is one wrapper in Server.Handler (retryCapped), on every
answer of 400 and up, not capAfter at four call sites. The patch
missed the vendor's own Retry-After passed on by keepRetry (19821s and
an HTTP date went out uncapped) and any other site that writes one.
The wrapper has Flush and Unwrap, so ResponseController and the
websocket's Hijack still reach the connection.
- settings.Shared() per answer, not settings.Load() from disk.
- The setting is reachable: settingsapi Keys and Merge (kept when not
sent), a Settings › Models › Replies row (1/5/15 min, No limit) with
zh, zh-TW, ja and de text, and prefsKeep. The patch failed
TestKeysAreWhatTheSaveWrites ("only saved: [retryAfterCap]").
- Stays opt-in: a default cap makes a backing-off client ask again
sooner, and each ask can spend a confirm probe on an exhausted account.
- Core script budget not raised; three app.js comments were shortened.
Run on mote at this head (rebased on 1493acb46):
- go test -tags nogui ./internal/gateway -run 'TestRetryAfter|
TestQuotaRestsUntilTheTimeOfDaySet|TestAllRestingAnswersFromRest': ok
(GoesOutWholeByDefault, CapBoundsTheAgentWait, CapLeavesTheRestWhole,
CapBoundsTheVendorsOwn, ALimitIsAsked, Rests).
- settingsapi/cli TestKeysAreWhatTheSaveWrites,
TestSettingsCLISetsWhatTheWindowSaves, TestBodySetsOneKeyOnly: ok.
- internal/gui Budget|I18n: ok.
- GUI, chromium + webkit: retry-after-cap-setting (new, 5 languages,
1100 and 420), refusal-retries-setting, settings-hints, i18n-keys,
i18n-en-no-cjk, reply-model-setting: 91 of 92. The one red is
i18n-keys "a plugin's words are its own", already filed as #5332 and
#5426 (strings outside this change).
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui on
gateway, settings, settingsapi: clean.
Broken by hand: with retryCapped taken out of Handler,
CapBoundsTheAgentWait fails (Retry-After "19252", want at most 60s) and
CapBoundsTheVendorsOwn fails (Retry-After "19821", want "60", and the
HTTP-date case). With the patch's own code, CapBoundsTheVendorsOwn fails
the same way.
Not tried: a real Antigravity account running out with a real OpenCode
fallback chain; the full suite.
Rebased onto 766d2a9f5's descendants: TestCoreScriptBudget was 1 byte
over (1533803 > 1533802) after ce2a59daa's app.js change; the new
row's comment lost a word. At the pushed head on mote:
TestCoreScriptBudget ok, -run RetryAfter ./internal/gateway ok.
Co-authored-by: ggbdpq <ggbdpq@gmail.com>