The coalition structure generation problem is now a big issue in the field of multi-agent systems. With many agents working in the same environment, cooperation may become a key point to complete a mission efficiently. This problem can also be found in many areas such as sensor networks, multi-robot systems, and even e-commerce. However, it has been proved to be NP-complete to find an optimal solution. In the paper, a stochastic algorithm called double-layered ant colony optimization is proposed to deal with the task-oriented coalition structure problem. Then, we evaluate the solution quality by comparing it with the optimal solutions derived by CPLEX. The results indicate that even though this method cannot guarantee the optimal solution, it can find a coalition structure that is good enough within a reasonably short time.