What is AutoGen?
Thanks to Ali Saleh for his contributions to this piece.
AutoGen is a framework that helps you easily create multi-agent applications. Multi-agent applications are a relatively recent idea that involve defining multiple LLM agents, each with their own goals and capabilities, and allowing them to work together to achieve an end goal.
The multi-agent approach often aims to replicate the structure of human teams and organizations. Agents are often personified and related to a single member of a team.
As a result, multi-agent frameworks are typically used to build:
- Customer service chatbots that can route to different “departments”
- Data analysis and research tools
- Content generation and editing applications
- Supply chain optimization
- Financial portfolio analysis and optimization
Any application that requires multi collaborators with different skill sets is usually a good candidate for automation through a multi-agent framework. AutoGen is one of the most popular tools used in creating these applications–mainly because it makes that creation process much easier and faster.
Let’s look at how it works.
What do Agents Look Like in AutoGen?
Defining agents in AutoGen is fairly simple. Each is made up of:
- A name and description
- A system prompt
- A config that specifies the LLM to use and any necessary API keys
data_analyzer_agent = AssistantAgent(
name="Data_Analyzer",
description="Provide insights, trends, or analysis based on the data and prompt.",
system_message="You are a helpful assistant that can provide insights, trends, or analysis based on the data and prompt.",
llm_config=llm_config,
)
Beyond these basic parameters, AutoGen also allows you to specify some more advanced ones. For example, you can equip an agent with the ability to run generated code in a contained docker environment.
Agents in AutoGen also take a specific type. The basic type is the AssistantAgent used above, which acts as a typical LLM assistant. Other types include a ConversableAgent, that plays a particular role in conversation, and a UserProxyAgent, that represents the end user.
How do you Attach Tools?
You can also equip your agent with tools. If you’ve used function calling via an existing LLM, these will look familiar. Tools are functions your agent can call. These could be connections to external systems, regular code logic blocks, or any other function you can think of.
These functions are defined as standard python functions, then passed to AutoGen using the framework’s register_tool function:
register_function(
run_sql_query,
caller=sql_query_agent,
executor=user_proxy_agent,
name="SQL_Query_Executor_Tool",
description="A tool that can be used to run SQL query on the database."
)
AutoGen will then pass along the descriptions of these functions, their name, and their parameters to the underlying LLM, which gives the agents the ability to call a particular tool.
Note: it is highly recommended to annotate function parameters as shown with the input parameter above. These annotations will pass through to the LLM, and instruct it on the value to use for that parameter.
How do the Agents Work Together?
Whether it’s a simple two-agent conversation or a complex group chat guided by a manager, AutoGen supports a wide variety of interactions, including sequential operations where agents follow a defined path. Each of these different approaches can be predefined in AutoGen, and can be composed together with each other.
Examples:
- Two-Agent Chat: Simple back-and-forth dialogue between agents.
- Sequential Chat: Agents operate in a defined sequence, ideal for task-oriented systems.
- Group Chat: Multiple agents converse, led by a manager who decides which agent will speak on each iteration.
In each of these chat structures, AutoGen will handle the communication between agents, and will allow them to continue chatting back and forth until one of two customizable conditions are met. Option 1 allows you to set a max number of turns that can be taken, after which the conversation will be summarized automatically. Option 2 lets you set a specific keyword that one of your agents can use to end the conversation and report the result directly.
What are the Benefits of Using AutoGen?
AutoGen makes the creation of multi-agent applications much easier. The prebuilt organization options that it provides make it easy to create order out of the chaos that can occasionally occur in more DIY multi-agent applications, and inclusions of tools like the UserProxyAgent help ensure the eventual output is sound, even if it means adding a few more iterations through the application.
All that said, it should be noted that multi-agent architectures in general can be tricky to get exactly right, and involve a good amount of prompt iteration, tool modification, and overall tinkering. Arize, and our open-source tool Phoenix, can make that process significantly smoother by providing visibility into what your group of agents is doing.
Check out our AutoGen integration with Phoenix to see this in action!