Merge pull request #204 from RuoJi6/RuoJi6/fix/issue-196-mainagent-reopen-task

feat(agent): support reopening and steering closed/paused tasks (#196)

# Conflicts:
#	server/orchestration.go
This commit is contained in:
ji ruo committed 2026-11-27 15:58:05 +08:00
commit f8c9728698
9 files changed
+726 -17

No files matched your search

+17
View File
@@ -911,6 +911,7 @@ func (s *Server) Handler() http.Handler {
mux.HandleFunc("PATCH /api/tasks/{id}/constraints/{cid}", s.editConstraint) // 约束管理:修改约束
mux.HandleFunc("DELETE /api/tasks/{id}/constraints/{cid}", s.deleteConstraint) // 约束管理:删除约束
mux.HandleFunc("POST /api/tasks/{id}/control", s.control)
mux.HandleFunc("POST /api/tasks/{id}/resume", s.resumeTask)
mux.HandleFunc("PUT /api/tasks/{id}/llm", s.updateTaskLLMProfiles)
mux.HandleFunc("GET /api/tasks/{id}/llm/resolution", s.taskLLMResolutionHandler)
mux.HandleFunc("POST /api/tasks/{id}/intents/{iid}/control", s.controlIntent)
@@ -1391,6 +1392,22 @@ func (s *Server) control(w http.ResponseWriter, r *http.Request) {
writeJSON(w, 200, result)
}
// resumeTask resumes a paused task or reopens a terminal task (done/failed/timeout)
// in place when it still has open goals or open intents.
func (s *Server) resumeTask(w http.ResponseWriter, r *http.Request) {
t, ok := s.lookupTask(r.PathValue("id"))
if !ok {
writeErr(w, 404, "task not found")
return
}
result, err := s.resumeOrReopenTask(t, agent.AbortPausedByUser)
if err != nil {
writeErr(w, 409, err.Error())
return
}
writeJSON(w, 200, result)
}
// controlIntent pauses, resumes, or cancels one local worker intent. A running
// worker is always stopped before state mutation/cleanup, preventing tool output
// that arrives after the user action from recreating deleted blackboard records.