Phase 06 · AI AgentsLesson 3 of 4
Microsoft AutoGen: Multi-Agent Systems
Agents that talk to each other to solve problems together.
The problem
Some tasks are too big or varied for one agent: one part needs planning, another needs writing code, another needs checking the result. Microsoft AutoGen is a framework for building multi-agent systems, where several agents with different roles talk to each other to complete a task together.
The concept
The core idea: agents in conversation#
In AutoGen, agents collaborate through messages, much like colleagues in a group chat. Each agent has a role, a system message (its instructions) and optionally tools or the ability to run code.
A classic two-agent pattern#
| Agent | Role |
|---|---|
| Assistant agent | An LLM that plans, writes code and suggests next steps |
Code executor agent (CodeExecutorAgent in v0.4) | Runs the code the assistant wrote and reports the output (or errors) back. In older v0.2 code this was the user proxy's job; in v0.4 UserProxyAgent only takes human input |
The loop:
- The task arrives: "Plot the last 30 days of this sales data."
- The assistant writes Python code.
- The executor runs it and returns the result or the error.
- The assistant reads the error, fixes the code, and tries again.
- They stop when the task is complete.
The write, run, fix loop
- Assistant writes Python code
- Executor runs itreturns the result or the error
- Assistant reads the errorfixes the code and tries again
Stop when the task is complete
This write → run → fix loop is what lets agents produce working code rather than plausible-looking code.
Team patterns#
| Pattern | How it works | Good for |
|---|---|---|
| Round-robin | Agents take turns in a fixed order | Structured review cycles (writer → critic → writer) |
| Selector / group chat | A model chooses which agent speaks next | Open-ended collaboration among specialists |
| Hand-off | One agent explicitly passes control to another | Customer-service style routing |
Ending the conversation#
Multi-agent chats need a clear termination condition: a maximum number of turns, a specific phrase such as TERMINATE, or a check that the goal is met.
AutoGen Studio#
AutoGen Studio is a low-code interface for designing agent teams visually: define agents, give them tools, and test conversations in a browser before writing production code. It's a quick way to prototype an idea.
Safety when agents run code#
Letting an agent execute code is powerful and risky. Run generated code inside an isolated environment (such as a Docker container), never with access to sensitive files or credentials, and review anything that touches real systems.
Try it
Your task · about 10 minutes
Run the v0.4 two-agent pattern from AutoGen's migration guide: an AssistantAgent writes a Python function and a CodeExecutorAgent runs it, in a RoundRobinGroupChat that stops on a termination condition. Read the conversation log end to end. (Starting a new project? Use Microsoft Agent Framework instead.)
Recap & next
Key takeaways
- AutoGen is Microsoft's framework for multi-agent conversations: agents with roles chat to complete a task.
- Typical roles (AutoGen v0.4): an AssistantAgent that plans and writes code, plus a CodeExecutorAgent that runs it and reports the output. In v0.4, UserProxyAgent only collects human input.
- Define a clear termination condition so conversations end when the task is done.
- AutoGen Studio offers a low-code interface for prototyping agent teams.
Quick check
2 questions · instant feedback
Go deeper
The full course on AI agents
Udemy course
Building AI Agents & Agentic AI System via Microsoft AutoGen
View course (opens Udemy in a new tab)
Want to train your team on this? Talk about corporate training
Finished this lesson?
Mark it complete to track your progress and keep your streak going.

