(taskID, status, result, errText, reason string)
| 624 | } |
| 625 | |
| 626 | func (rt *AgentTaskRuntime) finish(taskID, status, result, errText, reason string) { |
| 627 | rt.mu.Lock() |
| 628 | defer rt.mu.Unlock() |
| 629 | record := rt.records[taskID] |
| 630 | if record == nil { |
| 631 | return |
| 632 | } |
| 633 | record.Status = status |
| 634 | record.ResultText = result |
| 635 | record.ErrorText = errText |
| 636 | record.TerminationReason = reason |
| 637 | record.UpdatedAt = nowSeconds() |
| 638 | summary := "Worker completed." |
| 639 | message := result |
| 640 | if errText != "" { |
| 641 | summary = "Worker failed." |
| 642 | message = errText |
| 643 | } |
| 644 | rt.enqueueLocked(record, summary, message) |
| 645 | if _, terminal := terminalTaskStatuses[record.Status]; terminal { |
| 646 | rt.scheduleTerminalRecordCleanupLocked(taskID) |
| 647 | } |
| 648 | } |
| 649 | |
| 650 | func (rt *AgentTaskRuntime) setForegroundTaskTerminal(record *AgentTaskRecord, status, terminationReason string) { |
| 651 | if record == nil { |
no test coverage detected