autogen/website/docs/Use-Cases/agent_chat.md
Multi-agent Conversations  ### A Basic Two-Agent Conversation Example  Once the participating agents are constructed properly, one can start a multi-agent conversation session by an initialization step as shown in the following code:  ```python # the assistant receives a message from the user, which contains the task description user_proxy.initiate_chat(     assistant,     message="""What date is today? Which big tech stock has the largest year-to-date gain this year? How much is the gain?""", ) ```  After the initialization step, the conversation could proceed automatically. Find a visual illustration of how the user_proxy and assistant collaboratively solve the above task autonomously below: ![Agent Chat Example](images/agent_example.png)  1. The assistant receives a message from the user_proxy, which contains the task description. 2. The assistant then tries to write Python code to solve the task and sends the response to the user_proxy. 3. Once the user_proxy receives a response from the assistant, it tries to reply by either soliciting human input or preparing an automatically generated reply. If no human input is provided, the user_proxy executes the code and uses the result as the auto-reply. 4. The assistant then generates a further response for the user_proxy. The user_proxy can then decide whether to terminate the conversation. If not, steps 3 and 4 are repeated.  ### Supporting Diverse Conversation Patterns  #### Conversations with different levels of autonomy, and human-involvement patterns  On the one hand, one can achieve fully autonomous conversations after an initialization step. On the other hand, AutoGen can be used to implement human-in-the-loop problem-solving by configuring human involvement levels and patterns (e.g., setting the `human_input_mode` to `ALWAYS`), as human involvement is expected and/or desired in many applications.  #### Static and dynamic conversations  AutoGen, by integrating conversation-driven control utilizing both programming and natural language, inherently supports dynamic conversations. This dynamic nature allows the agent topology to adapt based on the actual conversation flow under varying input problem scenarios. Conversely, static conversations adhere to a predefined topology. Dynamic conversations are particularly beneficial in complex settings where interaction patterns cannot be predetermined.  1. Registered auto-reply  With the pluggable auto-reply function, one can choose to invoke conversations with other agents depending on the content of the current message and context. For example: - Hierarchical chat like in [OptiGuide](https://github.com/microsoft/optiguide). - [Dynamic Group Chat](https://github.com/microsoft/autogen/blob/main/notebook/agentchat_groupchat.ipynb) which is a special form of hierarchical chat. In the system, we register a reply function in the group chat manager, which broadcasts messages and decides who the next speaker will be in a group chat setting. - [Finite State Machine graphs to set speaker transition constraints](https://microsoft.github.io/autogen/docs/notebooks/agentchat_groupchat_finite_state_machine) which is a special form of dynamic group chat. In this approach, a directed transition matrix is fed into group chat. Users can specify legal transitions or specify disallowed transitions. - Nested chat like in [conversational chess](https://github.com/microsoft/autogen/blob/main/notebook/agentchat_chess.ipynb).  2. LLM-Based Function Call  Another approach involves LLM-based function calls, where LLM decides if a specific function should be invoked based on the conversation's status during each inference. This approach enables dynamic multi-agent conversations, as seen in scenarios like [multi-user math problem solving scenario](https://github.com/microsoft/autogen/blob/main/notebook/agentchat_two_users.ipynb), where a student assistant automatically seeks expertise via function calls.  ### Diverse Applications Implemented with AutoGen  The figure below shows six examples of applications built using AutoGen. ![Applications](images/app.png)  Find a list of examples in this page: [Automated Agent Chat Examples](../Examples.md#automated-multi-agent-chat) 