What AutoGen is
AutoGen is Microsoft’s framework for building applications where multiple AI agents hold a structured conversation to solve a task. Instead of one model call, you define agents with distinct roles and let them message each other — one writes code, another runs it, a third reviews. AutoGen’s core insight is that complex work is easier to orchestrate as a conversation with clear turn taking than as a single mega-prompt. The builder above generates a runnable script for the two most common patterns.
How it works
Every AutoGen agent is a message handler. The two foundational types are:
AssistantAgent— backed by an LLM. It receives the conversation so far and produces the next message, which may contain prose or fenced code.UserProxyAgent— represents the human. It starts the conversation withinitiate_chat, optionally pauses for human input, and crucially is the agent that executes code blocks (viacode_execution_config) and feeds results back.
For a single assistant, that two-agent loop is enough: the proxy sends the task, the assistant proposes code, the proxy runs it, errors come back, the assistant fixes them, and the loop continues until success or the reply cap.
For harder problems you add a GroupChat of specialist assistants — a
planner, a coder, a reviewer — managed by a GroupChatManager that picks who
speaks next. This separation of concerns produces noticeably better results on
multi-step coding tasks than one do-everything agent.
Tips and gotchas
- Always cap the loop. Set
max_consecutive_auto_replyandmax_round, and give the reviewer a clear termination signal (replyAPPROVED) so the conversation actually ends. - Use Docker in production.
use_docker=Falseis fine for local experiments, but executing model-written code on your host is risky — flip it on for anything real. - Keep temperature at 0 for code. Determinism makes debugging multi-agent runs far less maddening.
- Start with two agents. Reach for a group chat only when a single assistant visibly struggles — more agents means more tokens and more ways for the conversation to go sideways.