@@ -161,14 +161,14 @@ func IsContextOverflowError(err error) bool {
161161// statusCodeRegex matches HTTP status codes in error messages (e.g., "429", "500", ": 429 ")
162162var statusCodeRegex = regexp .MustCompile (`\b([45]\d{2})\b` )
163163
164- // ExtractHTTPStatusCode attempts to extract an HTTP status code from the error
164+ // extractHTTPStatusCode attempts to extract an HTTP status code from the error
165165// using regex parsing of the error message. This is a fallback for providers
166166// whose errors are not yet wrapped in *StatusError (the preferred path).
167167//
168168// The regex matches 4xx/5xx codes at word boundaries
169169// (e.g., "429 Too Many Requests", "500 Internal Server Error").
170170// Returns 0 if no status code found.
171- func ExtractHTTPStatusCode (err error ) int {
171+ func extractHTTPStatusCode (err error ) int {
172172 if err == nil {
173173 return 0
174174 }
@@ -191,7 +191,7 @@ func ExtractHTTPStatusCode(err error) int {
191191 return 0
192192}
193193
194- // IsRetryableStatusCode determines if an HTTP status code is retryable.
194+ // isRetryableStatusCode determines if an HTTP status code is retryable.
195195// Retryable means we should retry the SAME model with exponential backoff.
196196//
197197// Retryable status codes:
@@ -202,7 +202,7 @@ func ExtractHTTPStatusCode(err error) int {
202202// Non-retryable status codes (skip to next model immediately):
203203// - 429 (rate limit) - provider is explicitly telling us to back off
204204// - 4xx client errors (400, 401, 403, 404) - won't get better with retry
205- func IsRetryableStatusCode (statusCode int ) bool {
205+ func isRetryableStatusCode (statusCode int ) bool {
206206 switch statusCode {
207207 case 500 , 502 , 503 , 504 : // Server errors
208208 return true
@@ -219,7 +219,7 @@ func IsRetryableStatusCode(statusCode int) bool {
219219
220220// retryablePatterns contains error message substrings that indicate a
221221// transient/retryable failure. Numeric status codes (500, 502, etc.) are
222- // handled separately by ExtractHTTPStatusCode + IsRetryableStatusCode .
222+ // handled separately by extractHTTPStatusCode + isRetryableStatusCode .
223223var retryablePatterns = []string {
224224 "timeout" , // Generic timeout
225225 "connection reset" , // Connection reset
@@ -241,7 +241,7 @@ var retryablePatterns = []string{
241241
242242// nonRetryablePatterns contains error message substrings that indicate a
243243// permanent/non-retryable failure. Numeric status codes (429, 401, etc.) are
244- // handled separately by ExtractHTTPStatusCode .
244+ // handled separately by extractHTTPStatusCode .
245245var nonRetryablePatterns = []string {
246246 "rate limit" , // Rate limit message
247247 "too many requests" , // Rate limit message
@@ -292,8 +292,8 @@ func isRetryableModelError(err error) bool {
292292 }
293293
294294 // First, try to extract HTTP status code from known SDK error types
295- if statusCode := ExtractHTTPStatusCode (err ); statusCode != 0 {
296- retryable := IsRetryableStatusCode (statusCode )
295+ if statusCode := extractHTTPStatusCode (err ); statusCode != 0 {
296+ retryable := isRetryableStatusCode (statusCode )
297297 slog .Debug ("Classified error by status code" ,
298298 "status_code" , statusCode ,
299299 "retryable" , retryable )
@@ -387,17 +387,17 @@ func ClassifyModelError(err error) (retryable, rateLimited bool, retryAfter time
387387 if statusErr .StatusCode == http .StatusTooManyRequests {
388388 return false , true , statusErr .RetryAfter
389389 }
390- return IsRetryableStatusCode (statusErr .StatusCode ), false , 0
390+ return isRetryableStatusCode (statusErr .StatusCode ), false , 0
391391 }
392392
393393 // Fallback: providers that don't yet wrap (e.g. Bedrock), or non-provider
394394 // errors (network, pattern matching).
395- statusCode := ExtractHTTPStatusCode (err )
395+ statusCode := extractHTTPStatusCode (err )
396396 if statusCode == http .StatusTooManyRequests {
397397 return false , true , 0 // No Retry-After without StatusError
398398 }
399399 if statusCode != 0 {
400- return IsRetryableStatusCode (statusCode ), false , 0
400+ return isRetryableStatusCode (statusCode ), false , 0
401401 }
402402 return isRetryableModelError (err ), false , 0
403403}
0 commit comments