Overview

4 Exploring multi-agent systems

This chapter offers a practical tour of multi-agent systems, explaining how multiple specialized, LLM-driven agents collaborate to solve complex tasks through conversation, roles, tools, and workflows. It frames the strengths of multi-agent collaboration—internal feedback, critique, and division of labor—alongside the operational realities of verbosity, token consumption, and the brittleness of agent-authored code. The narrative moves from a hands-on introduction with AutoGen to an enterprise-flavored approach with CrewAI, using comparable scenarios to surface design patterns, coordination styles, and trade-offs.

With AutoGen, readers begin in AutoGen Studio, a conversational environment that pairs a UserProxy with one or more assistants to iteratively plan, generate, execute, and evaluate work products such as code and images. The platform supports multiple communication patterns (proxy, hierarchical, and group chat), making it easy to start with a proxy loop and then expand to collaborative group interactions to limit information loss across turns. Capabilities are extended via skills/actions (for example, adding a vision-based image description tool for validation), and software quality improves when adding critic agents that review and suggest refinements. Practical guidance covers execution isolation, caching to reduce token usage and resume work, and the differences between nested chats and group chat for clearer, shared context.

CrewAI introduces a role- and task-centric model for building “crews” that operate sequentially or under hierarchical control via a manager LLM. Agents are configured with explicit roles, backstories, goals, memory, and tools, then orchestrated through tasks to produce outputs—from joke writing to game-coding pipelines with QA and chief QA reviewers. The chapter also demonstrates observability with AgentOps, enabling detailed tracing of runs, token and cost accounting, and diagnostics for issues like repetitive loops. Readers learn when added structure and hierarchy can help (or inflate cost without commensurate gains), and how to tune roles, tasks, and processing patterns. The result is a balanced view: AutoGen and CrewAI each excel in different scenarios, and disciplined design, observability, and tool-based actions are key to building effective, cost-aware multi-agent systems.

How AutoGen agents communicate through conversations (AutoGen src.)
The user proxy and assistant agent communication (AutoGen src.)
The AutoGen interface and entering a task for the agents to work on
The output after the agents complete the task
The Build tab and steps to creating a new skill
Configuring the primary_assistant agent with the new skill
The generated file outputs from the agent work on the image generation task
The cache and working folders for AutoGen
The difference between nested and group chat for conversable agents
The composition of a CrewAI system
The AgentOps dashboard for running the Joke crew
Hierarchical processing of agents coordinated through a crew manager
The repetition of thoughts as they occurred within an agent run

Summary

  • AutoGen, developed by Microsoft, is a conversational multi-agent platform that employs a variety of agent types, such as user proxies and assistant agents, to facilitate task execution through natural language interactions.
  • AutoGen Studio acts as a development environment that allows users to create, test, and manage multi-agent systems, enhancing the usability of AutoGen.
  • AutoGen supports multiple communication patterns, including group chats and hierarchical and proxy communications. Proxy communication involves a primary agent (proxy) that interfaces between the user and other agents to streamline task completion.
  • CrewAI offers a structured approach to building multi-agent systems with a focus on enterprise applications. It emphasizes role-based and autonomous agent functionalities, allowing for flexible, sequential or hierarchical task management.
  • Practical exercises in the chapter illustrate how to set up and use AutoGen Studio, including installing necessary components and running basic multi-agent systems.
  • Agents in AutoGen can be equipped with specific skills to perform tasks such as code generation, image analysis, and data retrieval, thereby broadening their application scope.
  • CrewAI is distinguished by its ability to structure agent interactions more rigidly than AutoGen, which can be advantageous in settings that require precise and controlled agent behavior.
  • CrewAI supports integrating memory and tools for agents to consume through task completion.
  • CrewAI supports integration with observability tools like AgentOps, which provides insights into agent performance, interaction efficiency, and cost management.
  • AgentOps is an agent observability platform that can help you easily monitor extensive agent interactions.

FAQ

What is a multi-agent system and why use it instead of a single agent?Multi-agent systems use multiple specialized agents that can collaborate, critique, and provide feedback to one another. This internal evaluation loop often yields more complete, higher-quality outputs than a single agent, especially for complex tasks.
What is AutoGen Studio and how does it work?AutoGen Studio is a conversational multi-agent tool where a UserProxy coordinates with assistant agents to solve user-defined tasks. It supports patterns like proxy, hierarchical, and group chat, executing code, reviewing outputs, and iterating until results meet criteria.
What does the UserProxyAgent do in AutoGen?The UserProxyAgent acts as a stand-in for the human, delegating subtasks to assistants, executing generated code, and providing feedback. It drives an iteration loop—draft, run, evaluate—that continues until a termination condition or satisfactory result is reached.
How do I install and launch AutoGen Studio?Create a Python virtual environment, install the chapter requirements or pyautogen, set your OpenAI-compatible API key as an environment variable, then run “autogenstudio ui --port 8081” (change port if needed). Open the web UI in your browser to start chatting with agents.
How can I add skills (tools/actions) in AutoGen Studio?Use the Build tab to create a new Skill and paste the action code (e.g., a vision-based image inspection function). Attach the skill to the relevant agent/workflow so the agent can call it during tasks for execution, verification, or analysis.
What’s the difference between nested chats and group chats in AutoGen?Nested chats delegate conversation through a chain, which can distort information over iterations. Group chat puts agents in a shared channel (via GroupChat and GroupChatManager), improving transparency and collaboration but increasing verbosity and token usage.
How does caching in AutoGen help manage cost and long runs?AutoGen caches conversations and results to reduce repeated token usage and allow resuming long tasks. You can control cache location and seeds in code (e.g., with Cache.disk) to reproduce or continue runs deterministically.
How do I improve code quality with critics in AutoGen?Add a reviewer AssistantAgent and register a nested chat that triggers the critic after the engineer’s output. The critic inspects the latest code, flags issues, and suggests improvements, raising overall quality before finalization.
What is CrewAI and how does it differ from AutoGen?CrewAI organizes agents into a “crew” with explicit roles, tasks, and processes (sequential or hierarchical), typically without a user proxy. It emphasizes structured, role-based workflows with options for memory, caching, and rate limits, offering robust enterprise-oriented orchestration.
How can I observe and control costs and behavior with AgentOps?Integrate AgentOps (pip install, set AGENTOPS_API_KEY, call agentops.init()) to monitor runs, tokens, timings, and estimated costs. Dashboards reveal inefficiencies like repeated thoughts, helping you refine agents, processing patterns, or prompts to reduce cost and improve outcomes.