FEAT: 在模型请求失败时能够自动重试#82
Open
leeyyi wants to merge 1 commit into
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #82 +/- ##
==========================================
Coverage ? 87.46347%
==========================================
Files ? 418
Lines ? 40721
Branches ? 0
==========================================
Hits ? 35616
Misses ? 5105
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
2d23ed5 to
4335b2b
Compare
weimch
reviewed
Jun 16, 2026
| of not retrying. | ||
| """ | ||
|
|
||
| num_retries: int = Field(default=2, ge=0) |
weimch
reviewed
Jun 16, 2026
| namespaces, and message strings for the same condition. | ||
| """ | ||
|
|
||
| from __future__ import annotations |
weimch
reviewed
Jun 16, 2026
| @@ -0,0 +1,227 @@ | |||
| # Tencent is pleased to support the open source community by making tRPC-Agent-Python available. | |||
| `agent/config.py` 从环境变量构造: | ||
|
|
||
| ```python | ||
| ModelRetryConfig( |
weimch
reviewed
Jun 17, 2026
|
|
||
| model_config = ConfigDict(extra="forbid") | ||
|
|
||
| retryable_error_codes: list[str] = Field(default_factory=lambda: ["408", "409", "429", "500", "502", "503", "504"]) |
weimch
reviewed
Jun 17, 2026
| from pydantic import model_validator | ||
|
|
||
|
|
||
| class RetryRuleConfig(BaseModel): |
weimch
reviewed
Jun 17, 2026
| """Honor provider ``Retry-After`` or ``retry-after-ms`` hints when present.""" | ||
|
|
||
|
|
||
| class FixedBackoffConfig(BaseModel): |
weimch
reviewed
Jun 17, 2026
| """Honor provider ``Retry-After`` or ``retry-after-ms`` hints when present.""" | ||
|
|
||
|
|
||
| class RegisteredBackoffConfig(BaseModel): |
Contributor
There was a problem hiding this comment.
这里的类设计有问题,既然RegisteredBackoffConfig是让用户扩展的类,那么为啥FixedBackoffConfig没有继承RegisteredBackoffConfig呢
weimch
reviewed
Jun 17, 2026
| _BACKOFF_STRATEGIES[type_name] = strategy | ||
|
|
||
|
|
||
| class DefaultRetryPolicy(RetryPolicy): |
Contributor
There was a problem hiding this comment.
RetryPolicy和BackoffStrategy有啥区别
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.
No description provided.