fix(provider): 延长媒体超时并终止超时轮转

将图像和视频的默认 HTTP/轮询超时分别提高到 20 分钟和 30 分钟。媒体任务超时后直接失败,不再重试、切换客户端或标记为 upstream_submission_unknown。OpenAI 图像端点遇到上游明确拒绝 response_format 时自动移除并缓存兼容结论。

验证:go test ./... -count=1;go vet ./...;gofmt;相关 Shell bash -n、ShellCheck 与发布脚本回归测试。
This commit is contained in:
2026-08-05 13:58:02 +08:00
parent 9ce9053d7b
commit dd10a807df
23 changed files with 336 additions and 55 deletions
+4 -4
View File
@@ -153,7 +153,7 @@ func (c UniversalClient) universalSubmit(ctx context.Context, executor *scripten
func (c UniversalClient) universalPollUntilDone(ctx context.Context, executor *scriptengine.Executor, request Request, modelType string, upstreamTaskID string, payload map[string]any, requestID string, startedAt time.Time) (map[string]any, string, error) {
interval := universalDurationConfig(request.Candidate.PlatformConfig, 2*time.Second, "pollIntervalMs", "poll_interval_ms")
timeout := universalDurationConfig(request.Candidate.PlatformConfig, 10*time.Minute, "pollTimeoutMs", "poll_timeout_ms", "timeoutMs")
timeout := universalDurationConfig(request.Candidate.PlatformConfig, ProviderRequestTimeout(request.Kind), "pollTimeoutMs", "poll_timeout_ms", "timeoutMs")
deadline := time.NewTimer(timeout)
defer deadline.Stop()
ticker := time.NewTicker(interval)
@@ -234,7 +234,7 @@ func universalScriptContext(request Request, modelType string, payload map[strin
"platformModelId": request.Candidate.PlatformModelID,
"canonicalModelKey": request.Candidate.CanonicalModelKey,
"modelType": modelType,
"timeout": universalDurationConfig(request.Candidate.PlatformConfig, 10*time.Minute, "pollTimeoutMs", "poll_timeout_ms").Milliseconds(),
"timeout": universalDurationConfig(request.Candidate.PlatformConfig, ProviderRequestTimeout(request.Kind), "pollTimeoutMs", "poll_timeout_ms").Milliseconds(),
},
"env": cloneMapAny(request.Candidate.PlatformConfig),
"candidate": universalCandidateSnapshot(request),
@@ -318,7 +318,7 @@ func universalPostJSON(ctx context.Context, client *http.Client, baseURL string,
}
resp, err := client.Do(req)
if err != nil {
return nil, "", &ClientError{Code: "network", Message: err.Error(), Retryable: true}
return nil, "", transportClientError(err)
}
requestID := requestIDFromHTTPResponse(resp)
result, err := decodeHTTPResponse(resp)
@@ -335,7 +335,7 @@ func universalGetJSON(ctx context.Context, client *http.Client, url string, cred
}
resp, err := client.Do(req)
if err != nil {
return nil, "", &ClientError{Code: "network", Message: err.Error(), Retryable: true}
return nil, "", transportClientError(err)
}
requestID := requestIDFromHTTPResponse(resp)
result, err := decodeHTTPResponse(resp)