# Preface
In the chapter "Quick Guide to Building Single Agent", we have quickly built and operated a single agent. In this chapter, we will further break it down into multiple agents that collaborate with each other.

# Single Agent to Multi-Agent
Demo Path：[demo_startup_app_with_multi_agents](../../../../examples/startup_app/demo_startup_app_with_multi_agents)

n more complex scenarios, a single agent may not be sufficient to complete the task. We need multi-agent collaboration.

Taking the sample project of insurance Q&A as an example, users' questions may be quite varied, and sometimes the responses from a single agent can deviate from the topic. Driven by the expertise of certain specialists, we have divided this scenario into three agents: planning, executing, and expressing. We will then use the insurance consulting agent to connect them together.


## Sub-Agent
Using the experiences gained from building a single agent, we separately establish three agents for planning, executing, and expressing.

Planning Agent (Break down complex problems into manageable steps):
[question_rewrite_agent.yaml](../../../../examples/startup_app/demo_startup_app_with_multi_agents/intelligence/agentic/agent/agent_instance/insurance_planning_agent.yaml)


Executing Agent:
[question_planning_agent.yaml](../../../../examples/startup_app/demo_startup_app_with_multi_agents/intelligence/agentic/agent/agent_instance/insurance_executing_agent.yaml)

Expressing Agent:
[insurance_expressing_agent.yaml](../../../../examples/startup_app/demo_startup_app_with_multi_agents/intelligence/agentic/agent/agent_instance/insurance_expressing_agent.yaml)

## Master-Agent
[insurance_consult_agent.yaml](../../../../examples/startup_app/demo_startup_app_with_multi_agents/intelligence/agentic/agent/agent_instance/insurance_consult_agent.yaml)

The main agent connects several agents and tools in a logical sequence. It is important to pay attention to parameter passing; the agent_input serves as the thread context to store intermediate results for use by subsequent agents. The input and output fields of each agent can be customized according to requirements, and it is recommended to avoid duplication.

## Running Tests

Run [insurance_consult_pro_agent_test.py](../../../../examples/startup_app/demo_startup_app_with_multi_agents/intelligence/test/insurance_multi_agent_test.py)


**The execution result of the agent "question_planning_agent":**

```json
  {
    "sub_query_list": [
        "如何从保险产品A的基础版升级到更高版本？",
        "保险产品A升级版和尊享版的升级流程是什么？",
        "保险产品A升级时是否有额外的费用或条件需要满足？"
    ]
  }
```

**The final execution result of the insurance consultation agent:**

```text
保险产品A在保障期间内不支持直接升级。如果您想要从当前的基础版升级到升级版或尊享版，需要在当前保险期结束后，重新选择更高版本的保险产品进行投保。
请注意，升级时可能会有不同的保费标准，具体费用需依据您投保时的年龄和所选版本确定。
```

