← Back to DevBytes

Building a Software Dev Team with AutoGen Agents

What is a Software Dev Team with AutoGen Agents?

AutoGen is an open-source framework from Microsoft that enables the creation of conversational, multi-agent systems. In the context of software development, you can use AutoGen to simulate an entire engineering team—product manager, developer, QA engineer, and more—as a set of AI agents that collaborate autonomously to design, code, test, and refine software. Each agent has a distinct role, persona, and set of capabilities defined through prompts and tool access. They communicate in a structured conversation managed by AutoGen’s runtime, exchanging messages, running code, and making decisions together.

Instead of manually coordinating between different AI models or tools, you configure a team of agents once, and they handle the entire workflow: from clarifying requirements to writing production-ready code, running tests, and suggesting improvements. This approach turns a single AI assistant into a collaborative development squad that mirrors real-world agile teams.

Why It Matters

Traditional coding assistants work in isolation—they respond to a single prompt, often without deeper context or iterative refinement. AutoGen’s multi-agent architecture brings several critical advantages:

For development teams, this means accelerating prototyping, automating repetitive coding tasks, and even exploring design alternatives through structured agent conversations—all while keeping a human in the loop for final approval.

How to Build a Software Dev Team with AutoGen

Below is a step-by-step guide to creating a minimal but functional software development team using AutoGen. The team consists of three agents: a Product Manager (clarifies requirements), a Developer (writes code), and a QA Engineer (reviews and tests). We'll use Python and the autogen library. All code examples are complete and ready to run.

1. Install AutoGen and Dependencies

First, install the required packages. AutoGen works best with an LLM provider like OpenAI; we'll use GPT-4o. You need an API key set in the environment.

pip install autogen openai

Set your OpenAI API key as an environment variable:

export OPENAI_API_KEY="sk-..."  # Linux/macOS
# or on Windows: set OPENAI_API_KEY="sk-..."

2. Configure the LLM and Agent Settings

We'll define a shared configuration for the agents. Each agent uses the same LLM but with different system prompts and parameters. The config_list specifies the model and API access.

import autogen

config_list = [
    {
        "model": "gpt-4o",
        "api_key": os.environ.get("OPENAI_API_KEY"),
    }
]
llm_config = {
    "config_list": config_list,
    "temperature": 0.2,
    "timeout": 120,
}

3. Define Agent Roles and System Prompts

Each agent is an instance of autogen.AssistantAgent. Their behavior is shaped by a carefully crafted system message that defines their role, constraints, and interaction style. We also create a UserProxyAgent that acts as the human-in-the-loop and provides code execution capabilities.

# The Product Manager agent - clarifies and breaks down tasks
pm_agent = autogen.AssistantAgent(
    name="ProductManager",
    system_message=(
        "You are a product manager. Your job is to turn vague user requests into "
        "clear, actionable development tasks. When given a feature idea, ask clarifying "
        "questions, define acceptance criteria, and create a concise task description "
        "that a developer can implement. Do not write code yourself. Conclude with "
        "'TASK READY' and the final specification."
    ),
    llm_config=llm_config,
)

# The Developer agent - writes code based on the task spec
dev_agent = autogen.AssistantAgent(
    name="Developer",
    system_message=(
        "You are a senior software developer. You will receive a task specification from "
        "the ProductManager. Write clean, well-commented Python code to implement it. "
        "Include error handling and basic inline documentation. Output only the code in "
        "a single Python block. Do not ask questions back to the ProductManager; simply "
        "deliver the implementation."
    ),
    llm_config=llm_config,
)

# The QA agent - reviews code and runs tests
qa_agent = autogen.AssistantAgent(
    name="QAEngineer",
    system_message=(
        "You are a QA engineer. You will receive Python code from the Developer. "
        "Review it for bugs, edge cases, and adherence to the original task. "
        "Write and execute a minimal test script that validates the functionality. "
        "If tests pass, respond with 'CODE APPROVED'. Otherwise, suggest specific fixes "
        "and return the code to the Developer."
    ),
    llm_config=llm_config,
)

# The human proxy - provides initial input and can execute code
human_proxy = autogen.UserProxyAgent(
    name="User",
    human_input_mode="NEVER",   # set to "ALWAYS" if you want to approve each step
    max_consecutive_auto_reply=0,
    code_execution_config={
        "work_dir": "workspace",
        "use_docker": False,    # set to True if Docker is available
    },
)

code_execution_config allows agents to run Python code in a local directory. Docker can provide stronger isolation; here we use local execution for simplicity.

4. Create the Conversation Flow

AutoGen uses group chats to orchestrate multi-agent conversations. We'll set up a GroupChat with a moderator (the GroupChatManager) that routes messages based on agent roles. The custom speaker selection function ensures the conversation follows a logical order: User → PM → Developer → QA → back to User.

from autogen import GroupChat, GroupChatManager

# List all agents (the User proxy is typically the initiator)
agents = [human_proxy, pm_agent, dev_agent, qa_agent]

# Custom speaker selection to enforce workflow
def custom_speaker_selection(last_speaker, group_chat):
    """Determine the next speaker based on the workflow stage."""
    if last_speaker is human_proxy:
        return pm_agent      # User request goes to PM
    elif last_speaker is pm_agent:
        # PM's final message contains 'TASK READY'
        if "TASK READY" in group_chat.messages[-1]["content"]:
            return dev_agent
        else:
            return human_proxy   # PM asks a clarification, return to User
    elif last_speaker is dev_agent:
        return qa_agent       # Developer output goes to QA
    elif last_speaker is qa_agent:
        last_msg = group_chat.messages[-1]["content"]
        if "CODE APPROVED" in last_msg:
            return None       # End conversation
        else:
            return dev_agent  # Send back to Developer for fixes
    else:
        return None           # Fallback: stop

group_chat = GroupChat(
    agents=agents,
    messages=[],
    max_round=20,
    speaker_selection_method=custom_speaker_selection,
)

manager = GroupChatManager(
    groupchat=group_chat,
    llm_config=llm_config,
)

5. Launch the Team with a Task

Initiate the conversation by sending a user request from the human_proxy. The manager will automatically route the message to the Product Manager, and the workflow proceeds. Here we ask for a simple web scraping utility.

task = (
    "Create a Python function that fetches the title of a webpage given its URL. "
    "It should handle network errors gracefully and return the title as a string."
)

human_proxy.initiate_chat(
    manager,
    message=task,
    clear_history=True,
)

6. Full Script Example

Here is the complete, ready-to-run script combining all the steps above. Save it as dev_team_demo.py and run it after setting the API key.

import os
import autogen
from autogen import AssistantAgent, UserProxyAgent, GroupChat, GroupChatManager

# 1. Configuration
config_list = [
    {
        "model": "gpt-4o",
        "api_key": os.environ.get("OPENAI_API_KEY"),
    }
]
llm_config = {
    "config_list": config_list,
    "temperature": 0.2,
    "timeout": 120,
}

# 2. Define agents
pm_agent = AssistantAgent(
    name="ProductManager",
    system_message=(
        "You are a product manager. Your job is to turn vague user requests into "
        "clear, actionable development tasks. When given a feature idea, ask clarifying "
        "questions, define acceptance criteria, and create a concise task description "
        "that a developer can implement. Do not write code yourself. Conclude with "
        "'TASK READY' and the final specification."
    ),
    llm_config=llm_config,
)

dev_agent = AssistantAgent(
    name="Developer",
    system_message=(
        "You are a senior software developer. You will receive a task specification from "
        "the ProductManager. Write clean, well-commented Python code to implement it. "
        "Include error handling and basic inline documentation. Output only the code in "
        "a single Python block. Do not ask questions back to the ProductManager; simply "
        "deliver the implementation."
    ),
    llm_config=llm_config,
)

qa_agent = AssistantAgent(
    name="QAEngineer",
    system_message=(
        "You are a QA engineer. You will receive Python code from the Developer. "
        "Review it for bugs, edge cases, and adherence to the original task. "
        "Write and execute a minimal test script that validates the functionality. "
        "If tests pass, respond with 'CODE APPROVED'. Otherwise, suggest specific fixes "
        "and return the code to the Developer."
    ),
    llm_config=llm_config,
)

human_proxy = UserProxyAgent(
    name="User",
    human_input_mode="NEVER",
    max_consecutive_auto_reply=0,
    code_execution_config={
        "work_dir": "workspace",
        "use_docker": False,
    },
)

# 3. Group chat and workflow
agents = [human_proxy, pm_agent, dev_agent, qa_agent]

def custom_speaker_selection(last_speaker, group_chat):
    if last_speaker is human_proxy:
        return pm_agent
    elif last_speaker is pm_agent:
        if "TASK READY" in group_chat.messages[-1]["content"]:
            return dev_agent
        else:
            return human_proxy
    elif last_speaker is dev_agent:
        return qa_agent
    elif last_speaker is qa_agent:
        last_msg = group_chat.messages[-1]["content"]
        if "CODE APPROVED" in last_msg:
            return None
        else:
            return dev_agent
    else:
        return None

group_chat = GroupChat(
    agents=agents,
    messages=[],
    max_round=20,
    speaker_selection_method=custom_speaker_selection,
)

manager = GroupChatManager(
    groupchat=group_chat,
    llm_config=llm_config,
)

# 4. Start the workflow
task = (
    "Create a Python function that fetches the title of a webpage given its URL. "
    "It should handle network errors gracefully and return the title as a string."
)

human_proxy.initiate_chat(
    manager,
    message=task,
    clear_history=True,
)

When run, the agents will collaborate automatically. The Product Manager may ask a brief clarification (e.g., which HTTP library to use), then produce a task spec. The Developer writes code, the QA runs tests, and eventually the group chat concludes with approved, tested code in the workspace directory.

Best Practices

Conclusion

Building a software development team with AutoGen agents transforms AI from a single-query assistant into a coordinated, role-based engineering squad. By assigning specialized personas—product manager, developer, QA—and wiring them together with a clear conversational workflow, you can automate requirements clarification, code generation, testing, and iterative improvement in one seamless run. The tutorial above provides a complete, executable blueprint that you can extend with additional agents (e.g., security auditor, DevOps deployer) or adapt to your own development stack. As multi-agent architectures mature, they will become a core pattern for accelerating software delivery while keeping quality and human oversight at the center.

— Ad —

Google AdSense will appear here after approval

← Back to all articles