* fix(health): 放宽上游错误重试并保留健康边界 * fix(health): 补齐资源操作重放与上下文拒绝规则 * fix(execution): 保留明确请求拒绝的分类优先级 * fix(health): 补齐流内 HTTP 错误重试判断
20 lines
776 B
Go
20 lines
776 B
Go
package execution
|
|
|
|
import "strings"
|
|
|
|
// ExplicitRequestRejection 识别具体代码及明确的上下文超限,不以通用错误类型或任意消息子串终止重试。
|
|
func ExplicitRequestRejection(typeValue, codeValue, message string) bool {
|
|
for _, value := range []string{typeValue, codeValue} {
|
|
switch strings.ToLower(strings.TrimSpace(value)) {
|
|
case "context_length_exceeded", "invalid_parameter", "content_policy_violation":
|
|
return true
|
|
}
|
|
}
|
|
if !strings.EqualFold(strings.TrimSpace(typeValue), "invalid_request_error") || strings.TrimSpace(codeValue) != "" {
|
|
return false
|
|
}
|
|
message = strings.ToLower(strings.TrimSpace(message))
|
|
return strings.TrimSuffix(message, ".") == "prompt is too long" ||
|
|
strings.HasPrefix(message, "prompt is too long:")
|
|
}
|