MCPcopy Create free account
hub / github.com/astercloud/aster / CleanupSubagent

Method CleanupSubagent

pkg/tools/builtin/subagent_manager.go:301–330  ·  view source on GitHub ↗

CleanupSubagent 清理子代理资源

(taskID string)

Source from the content-addressed store, hash-verified

299
300// CleanupSubagent 清理子代理资源
301func (sm *FileSubagentManager) CleanupSubagent(taskID string) error {
302 sm.mu.Lock()
303 defer sm.mu.Unlock()
304
305 instance, exists := sm.agents[taskID]
306 if !exists {
307 return fmt.Errorf("subagent not found: %s", taskID)
308 }
309
310 // 如果还在运行,先停止
311 if instance.Status == "running" {
312 sm.mu.Unlock()
313 _ = sm.StopSubagent(taskID)
314 sm.mu.Lock()
315 // Agent 即将被删除
316 }
317
318 // 删除输出文件
319 outputFile := filepath.Join(sm.dataDir, taskID+".output")
320 _ = os.Remove(outputFile)
321
322 // 删除实例记录
323 delete(sm.agents, taskID)
324
325 // 删除实例文件
326 instanceFile := filepath.Join(sm.dataDir, taskID+".json")
327 _ = os.Remove(instanceFile)
328
329 return nil
330}
331
332// buildSubagentCommand 构建子代理启动命令
333func (sm *FileSubagentManager) buildSubagentCommand(config *SubagentConfig) (string, error) {

Callers

nothing calls this directly

Calls 4

StopSubagentMethod · 0.95
deleteFunction · 0.85
JoinMethod · 0.45
RemoveMethod · 0.45

Tested by

no test coverage detected