@@ -7,6 +7,7 @@ import (
77 "fmt"
88 "io"
99 "log/slog"
10+ "net/http"
1011 "regexp"
1112 "strconv"
1213 "strings"
@@ -492,12 +493,12 @@ func (a *anthropicClient) shouldRetry(attempts int, err error) (bool, int64, err
492493 return false, 0, fmt.Errorf("maximum retry attempts reached for rate limit: %d retries", maxRetries)
493494 }
494495
495− if apiErr.StatusCode == 401 {
496+ if apiErr.StatusCode == http.StatusUnauthorized {
496497 return false, 0, err
497498 }
498499
499500 // Handle context limit exceeded error (400 Bad Request)
500− if apiErr.StatusCode == 400 {
501+ if apiErr.StatusCode == http.StatusBadRequest {
501502 if adjusted, ok := a.handleContextLimitError(apiErr); ok {
502503 a.adjustedMaxTokens = adjusted
503504 slog.Debug("Adjusted max_tokens due to context limit", "new_max_tokens", adjusted)