Skip to main content
Article·microsoft.github.io
multi-agentconversablemicrosoftopen-sourceresearchorchestrationLLMautomation

AutoGen

AutoGen is a multi-agent conversation framework from Microsoft that allows multiple LLM agents to collaborate and solve tasks through automated chat. It supports customizable agent behaviors, human-in-the-loop interaction, and code execution sandboxing.

beginner15 minutes4 steps
The play
  1. Install AutoGen
    Install the AutoGen library using pip. This will give you the necessary tools to create and manage multi-agent conversations.
  2. Create an Assistant Agent
    Define an assistant agent. This agent will be responsible for assisting with tasks, answering questions, and providing support. Customize its system message to define its role and capabilities.
  3. Create a User Proxy Agent
    Define a UserProxyAgent. This agent acts as a proxy for the user, executing code, retrieving information, and interacting with the assistant agent. Set `human_input_mode` to "ALWAYS" to require human approval before code execution.
  4. Initiate the Conversation
    Start the conversation between the user proxy agent and the assistant agent. Provide a task or question to the user proxy, which will then interact with the assistant to find a solution.
Starter code
from autogen import AssistantAgent, UserProxyAgent

llm_config = {
    "config_list": config_list,
    "seed": 42,
}

assistant = AssistantAgent(
    name="assistant",
    llm_config=llm_config,
    system_message="You are a helpful assistant."
)

user_proxy = UserProxyAgent(
    name="user_proxy",
    human_input_mode="ALWAYS",
    max_consecutive_auto_reply=10,
    is_termination_msg=lambda x: x.get("content", "").rstrip().endswith("TERMINATE"),
    code_execution_config={"work_dir": "coding", "use_docker": False},
    llm_config=llm_config,
    system_message="""Reply TERMINATE if the task has been solved at full satisfaction.
Otherwise, reply CONTINUE, or the reason why the task is not solved yet.
""",
)

user_proxy.initiate_chat(
    assistant,
    message="What is the capital of France?"
)
Source
AutoGen — Action Pack