feat: add auto-recovery logic for chat completion clients#7567
Closed
Ricardo-M-L wants to merge 1 commit intomicrosoft:mainfrom
Closed
feat: add auto-recovery logic for chat completion clients#7567Ricardo-M-L wants to merge 1 commit intomicrosoft:mainfrom
Ricardo-M-L wants to merge 1 commit intomicrosoft:mainfrom
Conversation
…t errors Implements a wrapper client that adds configurable retry logic with exponential backoff and jitter to any ChatCompletionClient. Supports rate limit (429), server errors (500/502/503/504), timeout, and connection errors while correctly classifying permanent errors (auth, bad request) as non-retryable. Fixes microsoft#3632 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
|
Closing — this feature should have been discussed in an issue first before submitting a large PR. Apologies for the noise. |
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
Implements configurable auto-recovery logic for chat completion clients, addressing the need described in #3632.
RetryableChatCompletionClient: A wrapper that adds retry logic with exponential backoff and jitter to anyChatCompletionClientRetryConfig: Dataclass for configuring max retries, base/max delay, exponential base, jitter, retryable status codes, and error typesRetry-Aftervalues as minimum delayUsage
Files changed
python/packages/autogen-ext/src/autogen_ext/models/retry/__init__.py— Module exportspython/packages/autogen-ext/src/autogen_ext/models/retry/_retry_chat_completion_client.py— Core implementation (359 lines)python/packages/autogen-ext/tests/models/test_retry_chat_completion_client.py— 25 test cases (581 lines)Fixes #3632
Test plan
ChatCompletionClientmethods (close, usage, tokens, model_info)🤖 Generated with Claude Code