Skip to content

fix(http): do not retry HTTP 4xx client errors in _post - #2566

Open
morluto wants to merge 2 commits into
THUDM:mainfrom
morluto:fix/http-post-client-errors
Open

morluto wants to merge 2 commits into
THUDM:mainfrom
morluto:fix/http-post-client-errors

Conversation

@morluto

@morluto morluto commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2561.

Problem. _post in slime/utils/http_utils.py retries every exception up to max_retries=60 times with a 1 s sleep, also an httpx.HTTPStatusError for a 4xx response. The same request gets the same 4xx again, for example a prompt longer than the context length. So the caller sees the error only after about 60 s and 60 requests.

Change. In the except block, an httpx.HTTPStatusError with a 4xx status other than 408 and 429 is logged and raised after one request. Everything else is unchanged: 408, 429, 5xx and transport errors are still retried.

With --use-distributed-post, post still falls back to the local client after any actor error. So a 4xx is sent twice there (before: up to 2 x 60 times). This PR does not change that fallback.

Tests.

  • New tests/test_http_post_retry.py with httpx.MockTransport, asyncio.sleep patched and max_retries=3: 400, 404 and 422 send one request and raise. 408, 429, 500 and 503 send 3.
  • On main: 3 failed (400, 404 and 422 each sent 3 requests), 4 passed. With the fix: 7 passed.
  • The new file has NUM_GPUS = 0 and a __main__ block, and it is in the cpu-unittest list of pr-test.yml.j2 (pr-test.yml regenerated).
  • tests/test_server_control.py (23 passed) and tests/test_external_sglang_engines.py (5 passed).
  • ruff, black and isort from the pre-commit config pass on the changed files.
  • Not run: test_score_centering_binary.py (needs pybase64, not installed here). test_streaming_rollout.py has the same 2 failures on main and on this branch.

AI assistance: Claude Code wrote this change and its test, and ran the checks above, under my direction. I reviewed it and will answer the review.

A 4xx response other than 408 and 429 does not change when the same request is sent again. Raise it after one request instead of retrying it up to max_retries times.

Fixes THUDM#2561
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-25T17:32:12.789257Z
We couldn’t complete this review. Comment @codex review to try again.
e914763 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

CI runs each test file with python, not pytest. Without NUM_GPUS = 0 and a __main__ block, the file ran no tests. Add both, and add the file to the cpu-unittest list.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] http_utils._post retries HTTP 4xx responses 60 times

1 participant