feat(llm): 任务 LLM 配置链改为任何状态都可修改
任务结束(done/failed/timeout)后主 Agent 对话仍走任务配置链,链上模型出问题时 既不能改配置链、也就没法继续交互。去掉 HTTP 与 DB 事务两处终态拦截,前端弹窗 对终态任务同样开放编辑与保存(顺带修掉 queued 状态也不能编辑的口子)。 终态任务保存时不再重开额度阻塞意图:那些意图会从 blocked 挪到 open,既没有 worker 执行、也不再满足「重跑意图」的可重跑条件,反而变成死状态。终态任务想 继续跑仍走重跑意图/新增目标,由它们把任务重新 admit 回运行态。
This commit is contained in:
1 parent
db4f97ee95
commit
a2f7ac9747
6 files changed
+59
-31
No files matched your search
+10
-2
@@ -935,8 +935,9 @@ func (m *Manager) DeleteCompanyWithAssets(id int64, deleteAssets bool) (int64, e
|
||||
return assetsDeleted, nil
|
||||
}
|
||||
|
||||
// ReplaceTaskLLMProfiles resets a non-terminal task's ordered provider chain and
|
||||
// mirrors the committed state onto the live task handle.
|
||||
// ReplaceTaskLLMProfiles resets a task's ordered provider chain and mirrors the
|
||||
// committed state onto the live task handle. Terminal tasks are editable too —
|
||||
// their 主 Agent 对话 keeps running on the chain after the task finishes.
|
||||
func (m *Manager) ReplaceTaskLLMProfiles(id string, profileIDs []int64, activeProfileID int64) (int64, error) {
|
||||
n, err := strconv.ParseInt(id, 10, 64)
|
||||
if err != nil {
|
||||
@@ -954,6 +955,13 @@ func (m *Manager) ReplaceTaskLLMProfiles(id string, profileIDs []int64, activePr
|
||||
task.setLLMState(pt.LLMProfileID, pt.ActiveLLMProfileID, pt.LLMProfileIDs, pt.LLMChainRevision, pt.LLMFailoverState, pt.LLMFailoverReason)
|
||||
}
|
||||
m.mu.Unlock()
|
||||
// 终态任务不重开额度阻塞意图:任务已经没有 worker 在跑,重开只会把它们从
|
||||
// blocked 挪到 open——那里既没人执行,也不再满足「重跑意图」的可重跑条件,
|
||||
// 反而变成死状态。终态任务想接着跑,走重跑意图/新增目标,那条路会把任务重新
|
||||
// admit 回运行态。
|
||||
if pgdb.IsTerminal(pt.Status) {
|
||||
return 0, nil
|
||||
}
|
||||
if task, ok := m.Task(id); ok {
|
||||
reopened, reopenErr := task.Store.ReopenIntentsByBlockedReason(pgdb.IntentBlockedLLMQuota)
|
||||
if reopenErr != nil {
|
||||
|
||||
+3
-9
@@ -1511,10 +1511,8 @@ func (s *Server) updateTaskLLMProfiles(w http.ResponseWriter, r *http.Request) {
|
||||
writeErr(w, 404, "task not found")
|
||||
return
|
||||
}
|
||||
if isTerminalStatus(t.lifecycleSnapshot().Status) {
|
||||
writeErr(w, 409, "已结束的任务不能修改 LLM 配置")
|
||||
return
|
||||
}
|
||||
// 任何生命周期状态(含终态)都可以改链:任务结束后主 Agent 对话仍走这条链,
|
||||
// 模型不可用时不换链就等于把已完成任务的交互一起锁死。
|
||||
before := t.llmStateSnapshot()
|
||||
var req struct {
|
||||
LLMProfileIDs []int64 `json:"llm_profile_ids"`
|
||||
@@ -1534,11 +1532,7 @@ func (s *Server) updateTaskLLMProfiles(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
reopened, err := s.m.ReplaceTaskLLMProfiles(t.ID, req.LLMProfileIDs, active)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "terminal") {
|
||||
writeErr(w, 409, err.Error())
|
||||
} else {
|
||||
writeErr(w, 400, err.Error())
|
||||
}
|
||||
writeErr(w, 400, err.Error())
|
||||
return
|
||||
}
|
||||
// Profile edits affect only subsequent LLM calls. Existing in-flight calls
|
||||
|
||||
Reference in new issue
Block a user