@@ -583,7 +583,7 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
583583 yield chunk as any // Cast to any to bypass type checking since we know the structure is correct
584584 }
585585
586- // Re-throw with enhanced error message so retry system shows verbose details
586+ // Re-throw with enhanced error message for retry system
587587 const enhancedErrorMessage = this . formatErrorMessage ( error , this . getErrorType ( error ) , true )
588588 if ( error instanceof Error ) {
589589 const enhancedError = new Error ( enhancedErrorMessage )
@@ -670,7 +670,7 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
670670 // Since we're in a non-streaming context, we know the result is a string
671671 const errorMessage = errorResult as string
672672
673- // Create enhanced error with verbose details for retry system
673+ // Create enhanced error for retry system
674674 const enhancedError = new Error ( errorMessage )
675675 if ( error instanceof Error ) {
676676 // Preserve important properties from the original error
@@ -1089,7 +1089,7 @@ Please verify:
10891089 "throttl" ,
10901090 "rate" ,
10911091 "limit" ,
1092- "bedrock is unable to process your request" , // AWS Bedrock specific message
1092+ "bedrock is unable to process your request" , // AWS Bedrock specific throttling message
10931093 "please wait" ,
10941094 "quota exceeded" ,
10951095 "service unavailable" ,
@@ -1123,11 +1123,13 @@ Suggestions:
112311232. Split your request into smaller chunks
112411243. Use a model with a larger context window
112511254. If rate limited, reduce request frequency
1126- 5. Check your Amazon Bedrock quotas and limits` ,
1126+ 5. Check your Amazon Bedrock quotas and limits
1127+
1128+ {formattedErrorDetails}` ,
11271129 logLevel : "error" ,
11281130 } ,
11291131 SERVICE_QUOTA_EXCEEDED : {
1130- patterns : [ "service quota exceeded" , "quota exceeded " , "exceeded quota" , "limit exceeded"] ,
1132+ patterns : [ "service quota exceeded" , "service quota " , "quota exceeded for model " ] ,
11311133 messageTemplate : `Service quota exceeded. This error indicates you've reached AWS service limits.
11321134
11331135Please try:
@@ -1235,9 +1237,21 @@ Please check:
12351237 const errorMessage = error . message . toLowerCase ( )
12361238 const errorName = error . name . toLowerCase ( )
12371239
1238- // Check each error type's patterns
1239- for ( const [ errorType , definition ] of Object . entries ( AwsBedrockHandler . ERROR_TYPES ) ) {
1240- if ( errorType === "GENERIC" ) continue // Skip the generic type
1240+ // Check each error type's patterns in order of specificity (most specific first)
1241+ const errorTypeOrder = [
1242+ "SERVICE_QUOTA_EXCEEDED" , // Most specific - check before THROTTLING
1243+ "MODEL_NOT_READY" ,
1244+ "TOO_MANY_TOKENS" ,
1245+ "INTERNAL_SERVER_ERROR" ,
1246+ "ON_DEMAND_NOT_SUPPORTED" ,
1247+ "NOT_FOUND" ,
1248+ "ACCESS_DENIED" ,
1249+ "THROTTLING" , // Less specific - check after more specific patterns
1250+ ]
1251+
1252+ for ( const errorType of errorTypeOrder ) {
1253+ const definition = AwsBedrockHandler . ERROR_TYPES [ errorType ]
1254+ if ( ! definition ) continue
12411255
12421256 // If any pattern matches in either message or name, return this error type
12431257 if ( definition . patterns . some ( ( pattern ) => errorMessage . includes ( pattern ) || errorName . includes ( pattern ) ) ) {
0 commit comments