界面已本地化;技能介绍与说明文档按所选语言由 AI 自动翻译,代码、命令、路径和专业术语保留原文,以原作者文档为准。
探索技能
开发与工程 · SKILL.md

autogen

autogen

【开发与工程】Build conversational multi-agent systems with Microsoft AutoGen. AssistantAgent, UserProxyAgent, GroupChat, code execution, nested chats, cancellation tokens, tool integration, and MCP support. Use when building conversation-driven multi-agent systems or comparing agent frameworks. Do not use this skill for unrelated requests; route to the nearest na…

独立 GitHub 快照 · 自动分类 · 以原作者文档为准

技能说明

GitHub

name: autogen description: >- Build conversational multi-agent systems with Microsoft AutoGen. AssistantAgent, UserProxyAgent, GroupChat, code execution, nested chats, cancellation tokens, tool integration, and MCP support. Use when building conversation-driven multi-agent systems or comparing agent frameworks. Do not use this skill for unrelated requests; route to the nearest named specialist. license: MIT metadata: author: Magnus Hedemark version: 1.2.0 source: https://microsoft.github.io/autogen

AutoGen Expert Skill

This skill targets the AutoGen AgentChat 0.7.5 API on Python 3.10+. AutoGen (by Microsoft Research) is a framework for conversational multi-agent AI. Unlike LangGraph's explicit graph topology or CrewAI's role-based crews, AutoGen uses agent-to-agent conversations as the orchestration primitive. Agents communicate through structured chat, with built-in patterns for group chat routing, human input, and code execution.

Core Paradigm

from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.ui import Console
from autogen_ext.models.openai import OpenAIChatCompletionClient

model_client = OpenAIChatCompletionClient(model="gpt-4o-mini")

assistant = AssistantAgent(
    name="assistant",
    system_message="You are a helpful assistant.",
    model_client=model_client,
)

Role split in AgentChat 0.7.5: UserProxyAgent represents a human and obtains replies through input_func. CodeExecutorAgent executes code blocks using a CodeExecutor. They are separate agents; neither accepts the legacy human_input_mode option.

Core Principles

  1. Conversations are the orchestration primitive. Agents send messages, receive replies, and the conversation structure determines the workflow.
  2. Keep human input and code execution separate. Use UserProxyAgent for a human participant; use CodeExecutorAgent with a CodeExecutor for code.
  3. GroupChat routes between agents. RoundRobinGroupChat cycles fixed-order. SelectorGroupChat uses an LLM to pick the next speaker.
  4. Nested chats delegate work. An agent can spawn a sub-conversation between specialist agents and return the result.
  5. Docker is the safe code execution mode. Local code execution (LocalCommandLineCodeExecutor) runs LLM-generated code on your machine — use Docker in production.
  6. Cancellation tokens stop runaway agents. Always pass CancellationToken for long-running tasks.

Where to Start

You already have...Start here
Nothing — exploring AutoGenCreate an assistant chat or a team with a human UserProxyAgent
Agents that need to coordinateBuild a GroupChat with multiple agents
Agents that need code executionConfigure Docker code executor
A complex multi-step taskUse nested chats for sub-tasks

Quick Reference

TaskApproachReference
Human-in-the-loop chatAssistantAgent + UserProxyAgentreferences/agent-types.md
Multi-agent groupGroupChat with RoundRobinGroupChatreferences/group-chat.md
Code executionDockerCommandLineCodeExecutorreferences/code-execution.md
Tool integrationregister_function() or @toolreferences/tool-integration.md
Nested chatAgentTool or a team run from a toolreferences/conversation-patterns.md
CancellationCancellationTokenreferences/conversation-patterns.md
MCP toolsMcpWorkbenchreferences/tool-integration.md

Framework Routing Guide

ScenarioReach forWhy
Conversation-driven multi-agentAutoGenNative agent-to-agent chat as orchestration
Role-based multi-agent teamsCrewAIRole/Goal/Backstory is the native abstraction
State-machine multi-agentLangGraphGraph topology, subgraphs, human-in-the-loop
Chain/agent compositionLangChainLCEL pipe operator for general chains

Reference Files

ReferenceLoad whenFile
Agent TypesAssistantAgent, UserProxyAgentreferences/agent-types.md
Conversation PatternsSend/receive, nested chats, cancellationreferences/conversation-patterns.md
Group ChatRoundRobin, Selector, MagenticOnereferences/group-chat.md
Code ExecutionDocker, local, cancellation tokensreferences/code-execution.md
Tool Integrationregister_function, @tool, MCP integrationreferences/tool-integration.md
v0.4 Migrationv0.2->v0.4 migration, AgentTool, streaming, terminationreferences/v04-migration.md
Validation AuditResearch validation of all API claimsreferences/validation-audit.md
FAQ & TroubleshootingCommon errors and fixesreferences/faq-and-troubleshooting.md

Install the exact package versions used by the templates with python -m pip install -r requirements.txt from this skill directory. The code-execution example uses Docker and requires a working Docker daemon.

Templates

TemplateWhen to useFile
Two-Agent ChatAssistant + human inputtemplates/two-agent-chat.py
Group ChatMulti-agent team with speaker routingtemplates/group-chat.py
Code Execution AgentAssistant + Docker-backed code executortemplates/code-execution.py

Troubleshooting

SymptomLikely causeFixReference
Agent loops foreverNo team termination conditionAdd a TerminationCondition such as MaxMessageTerminationreferences/conversation-patterns.md
Code execution failsDocker not runningStart Docker or use LocalCommandLineCodeExecutorreferences/code-execution.md
Nested chat never returnsCancellation token not passedPass CancellationToken with timeoutreferences/conversation-patterns.md
v0.2 code doesn't workv0.4 API changedFollow migration guidereferences/faq-and-troubleshooting.md
GroupChat speaker selection loopsSelectorGroupChat with no clear nextUse RoundRobinGroupChat for fixed orderreferences/group-chat.md
UserProxyAgent waits for inputIt is a human participant and its input_func is waitingSupply an appropriate input function or use an automated agentreferences/agent-types.md

When NOT to Use AutoGen

  • Simple single-agent task — overkill, use direct API call
  • Need fine-grained graph control — use LangGraph
  • Need role-based teams with fixed processes — use CrewAI
  • Need chain composition — use LangChain LCEL
我的收藏