From 9d40159cad3b55c753ed02e7a4dee8cc7b6d15eb Mon Sep 17 00:00:00 2001 From: dev Date: Wed, 21 Oct 2026 18:37:27 +0000 Subject: Add request timeout and retry support to aichat HTTP clients - Add timeout, retries, retry_delay_ms, and retry_max_delay_ms options to client extra config to bound long-running requests and retry failed attempts with exponential backoff. - Apply a total request timeout via reqwest .timeout(). - Implement retry with exponential backoff for non-streaming and streaming chat completions. - Disable reqwest-eventsource internal auto-reconnect so it does not loop forever; outer retry logic is now the single owner of retry behavior. - Document the new options in config.example.yaml. --- config.example.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'config.example.yaml') diff --git a/config.example.yaml b/config.example.yaml index 4cac6c0..24e4cf9 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -116,6 +116,18 @@ clients: # extra: # proxy: socks5://127.0.0.1:1080 # Set proxy # connect_timeout: 10 # Set timeout in seconds for connect to api + # timeout: 600 # Set total request timeout in seconds (0 or omitted disables) + # retries: 3 # Number of retries after the first failed attempt (0 disables) + # retry_delay_ms: 1000 # Base delay between retries in milliseconds (default 1000) + # retry_max_delay_ms: 60000 # Cap exponential backoff delay in milliseconds (default uncapped) + + # A note on long-running providers (e.g. background/queued inference): + # A non-streaming request may hold one HTTP connection for minutes. If the + # connection is dropped by an intermediary, the client otherwise waits + # forever. Set `timeout` to bound each attempt, and `retries` to re-submit + # when an attempt fails. Be aware that retrying a non-idempotent request + # may resubmit the same work; prefer streaming (stream: true) for + # long-running requests so data flows continuously over the wire. # See https://platform.openai.com/docs/quickstart - type: openai -- cgit v1.2.3