fix(#1743): retry primary model on transient errors even without fallback models#1744
Draft
aheritier wants to merge 1 commit intodocker:mainfrom
Draft
fix(#1743): retry primary model on transient errors even without fallback models#1744aheritier wants to merge 1 commit intodocker:mainfrom
aheritier wants to merge 1 commit intodocker:mainfrom
Conversation
…t fallback models getEffectiveRetries returned 0 when no fallback models were configured, meaning retryable errors (5xx, timeouts) got zero retries. This caused Anthropic streaming 'Internal server error' to immediately surface as 'all models failed' instead of being retried with backoff. Changed getEffectiveRetries to always return DefaultFallbackRetries (2) when no explicit retry count is configured, regardless of whether fallback models exist. Retrying the same model on transient errors is always valuable. Fixes docker#1743 Assisted-By: cagent
881b4c7 to
b951002
Compare
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
Fixes #1743
getEffectiveRetriesreturned 0 when no fallback models were configured, meaning retryable errors (5xx, timeouts) got zero retries. This caused Anthropic streamingInternal server errorto immediately surface as"all models failed"instead of being retried with backoff.Root Cause
The
getEffectiveRetriesfunction conflated "no fallback models to fall back to" with "no need to retry the same model":With
maxAttempts = 1 + 0 = 1, even correctly-classified retryable errors got exactly one shot.Fix
Changed
getEffectiveRetriesto always returnDefaultFallbackRetries(2 retries = 3 total attempts) when no explicit retry count is configured, regardless of whether fallback models exist:Tests
TestGetEffectiveRetriesto expectDefaultFallbackRetriesfor agents without fallback modelsTestPrimaryRetriesWithoutFallbackModels— regression test reproducing the exact scenario (Anthropic streamingInternal server error, no fallback models, verifies retry and recovery)isRetryableModelErrortest case for the Anthropic streaming error format