Skip to content

Retry transient HTTP errors in the agent fetch transport - #3291

Closed
Mattbusel wants to merge 1 commit into
perspective-dev:masterfrom
Mattbusel:use-llm-wasm
Closed

Mattbusel wants to merge 1 commit into
perspective-dev:masterfrom
Mattbusel:use-llm-wasm

Conversation

@Mattbusel

Copy link
Copy Markdown

fetch_completion in agent/client/transport.rs turns any non-ok response into an error on the first try, so a single 429 or 503 from the provider ends the whole agent turn, and Retry-After is never read. This PR retries 429/500/502/503/504 up to three attempts with jittered backoff (honoring a delta-seconds Retry-After when the response exposes it, and giving up as before if it asks for more than 30s), waiting on set_timeout so the Stop button still cancels. The policy comes from llm-wasm (no I/O, builds for wasm32), pulled in only through the existing llm-agent feature; 4xx errors like the 401 spec behave exactly as before. cargo clippy -p perspective-viewer --target wasm32-unknown-unknown is clean and prettier/rustfmt pass; I added a 503-then-200 case to agent_http.spec.ts next to the 401 one but could not run the Playwright suite locally without the full emscripten build. I maintain llm-wasm (MIT) and will keep it current.

Signed-off-by: Matthew Charles Busel <mattbusel@gmail.com>
@texodus

texodus commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Please consult the CONTRIBUTING.md before opening a PR:

... but could not run the Playwright suite locally without the full emscripten build.

Additionally in this case, while this may be an issue, timer retries are not a solution, especially when the thing you are retrying can cost $/req (an associated Issue would've driven this out, which is why it is a requirement for first-time contributors).

@texodus texodus closed this Nov 15, 2026
@perspective-dev perspective-dev locked as resolved and limited conversation to collaborators Nov 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants