OnAgentStop 清理子代理
(ctx context.Context, agentID string)
| 165 | |
| 166 | // OnAgentStop 清理子代理 |
| 167 | func (m *SubAgentMiddleware) OnAgentStop(ctx context.Context, agentID string) error { |
| 168 | m.mu.Lock() |
| 169 | defer m.mu.Unlock() |
| 170 | |
| 171 | for name, agent := range m.agents { |
| 172 | if err := agent.Close(); err != nil { |
| 173 | saLog.Error(context.Background(), "failed to close subagent", map[string]any{"name": name, "error": err.Error()}) |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | return nil |
| 178 | } |
| 179 | |
| 180 | // GetSubAgent 获取子代理 |
| 181 | func (m *SubAgentMiddleware) GetSubAgent(name string) (SubAgent, error) { |