fix(channels): catch ConnectTimeout/WriteTimeout and handle non-numeric Retry-After (#642) - #645
Closed
Tiktokaiagent wants to merge 3 commits into
Closed
Conversation
1 task
Tiktokaiagent
force-pushed
the
fix/642-retry-request-timeouts
branch
from
September 1, 2026 01:28
bbfde7b to
53e705b
Compare
…ic Retry-After Fixes two bugs in retry_request: 1. httpx.ConnectTimeout and WriteTimeout are not subclasses of ConnectError — they inherit from TimeoutException via a separate hierarchy. Added TimeoutException to the catch clause. 2. Retry-After header can be an HTTP-date string per RFC 7231 §7.1.3, not just delay-seconds. A bare float() call crashes on non-numeric values. Added try/except fallback to default backoff delay. Fixes use-agent-os#642
…y-After (use-agent-os#642) ## Tests (6 new) - test_retry_429_with_numeric_retry_after - test_retry_429_with_http_date_retry_after_falls_back - test_retry_429_with_empty_retry_after_falls_back - test_retry_connect_timeout - test_retry_generic_timeout_exception - test_retry_exhausted_raises_last_exception ## Verification - uv run pytest tests/test_channels/test_channel_retry_util.py -v — 6 passed - uv run pytest tests/test_channels/ -q — 48 passed (was 42)
Tiktokaiagent
force-pushed
the
fix/642-retry-request-timeouts
branch
from
September 1, 2026 17:30
a80604d to
f9b3827
Compare
Contributor
|
Closing in favor of #782, which landed for #642 and #599 together — the issue thread asked for the three defects in |
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.
Summary
Fixes two bugs in
retry_requestthat cause unnecessary crashes in production:Missing timeout exception types —
httpx.ConnectTimeoutandWriteTimeoutinherit fromTimeoutException, notConnectError. Addedhttpx.TimeoutExceptionto the catch clause so all transient timeouts (DNS, TLS, write, pool) are retried instead of crashing.Non-numeric Retry-After crash — Per RFC 7231 §7.1.3,
Retry-Aftercan be an HTTP-date string (e.g.Wed, 21 Oct 2026 07:28:00 GMT). A barefloat()call on such values causes aValueErrorcrash. Added try/except fallback to the standard exponential backoff delay.Changes
src/agentos/channels/_util.py: Addedhttpx.TimeoutExceptionto retry catch clausesrc/agentos/channels/_util.py: Wrappedfloat(Retry-After)in try/except with fallback tobase_delay * (2**attempt)Tests
6 new regression tests in
tests/test_channels/test_channel_retry_util.py:All channel tests still pass:
Fixes #642