fix(tasks): 任务队列 - 执行前重查排队任务的自定义渠道开关 (#682)
Co-authored-by: ddcat666 <26564566+ddcat666@users.noreply.github.com>
This commit is contained in:
@@ -191,6 +191,34 @@ func (w *taskWorkerCoordinator) processClaimedTask(task *model.Task, globalSlot
|
||||
return s.finishTaskMediaRecovery(task, result, recoveryErr)
|
||||
}
|
||||
|
||||
// Creation and manual retry admission can precede execution by a long time.
|
||||
// Re-read the feature policy before preparing or dispatching a model route.
|
||||
decryptedInput, err := s.decryptTaskInputJSON(task.InputJSON)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var admissionInput map[string]any
|
||||
if err := json.Unmarshal([]byte(decryptedInput), &admissionInput); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.requireCustomChannelsForTaskInput(admissionInput); err != nil {
|
||||
// A reclaimed task may already have submitted upstream. Keep the existing
|
||||
// review path for that evidence; only an unsent reservation is refundable.
|
||||
attempts, readErr := s.repo.RouteAttempts(task.ID, task.RouteRun)
|
||||
uncertain := readErr != nil || task.ProviderRequestID != "" || s.taskBilling().BillingFailureRequiresReview(task.BillingOrderID, task.ID, err)
|
||||
for _, attempt := range attempts {
|
||||
if attempt.DispatchState == "accepted" || attempt.DispatchState == "submission_unknown" {
|
||||
uncertain = true
|
||||
}
|
||||
}
|
||||
// Legacy tasks without an explicit new retry run retain their conservative
|
||||
// submission handling, as in createDirectTaskAttempt.
|
||||
if len(attempts) == 0 && task.RouteRun <= 1 && task.Attempts > 1 {
|
||||
uncertain = true
|
||||
}
|
||||
return terminal.markPreparationFailure(task, "渠道不可用", errors.Join(err, readErr), uncertain, "自定义渠道已关闭,上游请求未发出")
|
||||
}
|
||||
|
||||
s.markAgentMemoryCompactRunning(*task)
|
||||
task.Stage = "调用生成模型"
|
||||
task.Progress = 35
|
||||
|
||||
Reference in New Issue
Block a user