Fix streaming rate limit error handling and retry logic
Analysis of debug.log showed 429 rate limit errors during streaming were not being caught by the retry logic because: 1. Streaming generators don't raise exceptions until consumed 2. Error message 'Claude API error (429): Error' didn't contain retry keywords Changes: 1. Added _handle_streaming_request_with_retry() wrapper that catches rate limit errors and re-raises with proper keywords 2. Added _wrap_streaming_with_retry() method that consumes streaming generator and retries with fallback models on rate limit errors 3. Updated retry logic to check for '429' keyword in error messages 4. Added exponential backoff with jitter before retry attempts 5. Improved error messages to include rate limit context This ensures that when streaming hits a 429 rate limit, the system will automatically retry with fallback models instead of failing.
Showing
Please
register
or
sign in
to comment