fix: streaming timeout retry + progress keepalive during long inference#1749
Open
gdeyoung wants to merge 1 commit into
Open
fix: streaming timeout retry + progress keepalive during long inference#1749gdeyoung wants to merge 1 commit into
gdeyoung wants to merge 1 commit into
Conversation
- Add httpx.ReadTimeout/ConnectTimeout/PoolTimeout to transient error types - Allow retry for transient errors even with partial streaming chunks - Add background heartbeat task emitting progress every 10s during long LLM calls - Keeps Socket.IO connection warm during 30-90s inference gaps Fixes session death during large context (500K+ token) processing.
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.
Fix: Streaming timeout retry + progress keepalive during long inference
Problem
During long LLM inference (30-90s for 500K+ token contexts), two bugs cause session death:
Transient timeout classification:
httpx.ReadTimeout(originating fromaiohttp.SocketTimeoutErrorvia LiteLLM's transport) is not classified as transient in_is_transient_litellm_error(), so streaming timeouts are never retried.Partial-chunk guard blocks retries: The
got_any_chunkguard blocks ALL retries once any streaming data is received, even for transient errors.Fix
Part 1: Transient classification (models.py)
Add httpx timeout exceptions to the
transient_typestuple:Part 2: Retry condition (models.py)
Allow retries for transient errors even when partial chunks were received:
Part 3: Progress keepalive (agent.py)
Wrap
call_chat_modelwith a background heartbeat task that emits progress events every 10s during long inference, keeping the Socket.IO connection warm:Testing