ag2

AG2(前身为 AutoGen)专家:一个开源的多智能体对话框架。帮助开发者构建使多个 AI 智能体通过结构化对话协作的系统,支持工具使用、人在回路、代码执行、群聊编排和嵌套对话,应用于软件开发、研究和数据分析等复杂任务。

仓库最近推送
GitHub Stars
219
Forks
38
Issues / PRs
1

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "ag2":https://skillpi.com/zh/skills/deepskill-73f0c11a6557e499003830dcfad3ed45363fbfab226d4550c43f41497f88136b。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

AG2(前身为 AutoGen)专家:一个开源的多智能体对话框架。帮助开发者构建使多个 AI 智能体通过结构化对话协作的系统,支持工具使用、人在回路、代码执行、群聊编排和嵌套对话,应用于软件开发、研究和数据分析等复杂任务。

0 下载

介绍来源: third_party · TerminalSkills · 1.0.0 参考来源

SkillPi 解读

输入和输出
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: ag2
description: >-
  You are an expert in AG2 (formerly AutoGen), the open-source multi-agent
  conversation framework. You help developers build systems where multiple AI
  agents collaborate through structured conversations — with tool use,
  human-in-the-loop, code execution, group chat orchestration, and nested
  conversations — for complex tasks like software development, research, and
  data analysis.
license: Apache-2.0
compatibility: ''
metadata:
  author: terminal-skills
  version: 1.0.0
  category: AI & Machine Learning
  tags:
    - multi-agent
    - conversation
    - autogen
    - microsoft
    - orchestration
    - python

AG2 (AutoGen) — Multi-Agent Conversation Framework

You are an expert in AG2 (formerly AutoGen), the open-source multi-agent conversation framework. You help developers build systems where multiple AI agents collaborate through structured conversations — with tool use, human-in-the-loop, code execution, group chat orchestration, and nested conversations — for complex tasks like software development, research, and data analysis.

Core Capabilities

Two-Agent Conversation

from autogen import ConversableAgent, UserProxyAgent

# AI assistant agent
assistant = ConversableAgent(
    name="Engineer",
    system_message="""You are a senior software engineer.
    Write clean, tested Python code. Explain your design decisions.""",
    llm_config={"model": "gpt-4o", "temperature": 0.2},
)

# Human proxy (can auto-approve or require human input)
user_proxy = UserProxyAgent(
    name="User",
    human_input_mode="NEVER",             # NEVER / ALWAYS / TERMINATE
    max_consecutive_auto_reply=10,
    is_termination_msg=lambda msg: "TERMINATE" in msg.get("content", ""),
    code_execution_config={
        "work_dir": "workspace",
        "use_docker": True,               # Safe code execution in Docker
    },
)

# Start conversation — agents talk until task is complete
result = user_proxy.initiate_chat(
    assistant,
    message="Create a FastAPI app with user authentication using JWT. Include tests.",
)
# Engineer writes code → User proxy executes → Engineer reviews output → iterates

Group Chat (Multiple Agents)

from autogen import GroupChat, GroupChatManager

# Specialist agents
architect = ConversableAgent(
    name="Architect",
    system_message="You design system architecture. Focus on scalability, reliability, and clean interfaces.",
    llm_config={"model": "gpt-4o"},
)

developer = ConversableAgent(
    name="Developer",
    system_message="You implement features based on the architect's design. Write production-quality code.",
    llm_config={"model": "gpt-4o"},
)

reviewer = ConversableAgent(
    name="Reviewer",
    system_message="You review code for bugs, security issues, and best practices. Be thorough but constructive.",
    llm_config={"model": "gpt-4o"},
)

tester = ConversableAgent(
    name="Tester",
    system_message="You write comprehensive tests. Cover edge cases and integration scenarios.",
    llm_config={"model": "gpt-4o"},
)

# Group chat with round-robin or AI-selected speaker
group_chat = GroupChat(
    agents=[user_proxy, architect, developer, reviewer, tester],
    messages=[],
    max_round=20,
    speaker_selection_method="auto",      # LLM picks next speaker based on context
)

manager = GroupChatManager(groupchat=group_chat, llm_config={"model": "gpt-4o"})

user_proxy.initiate_chat(
    manager,
    message="Build a real-time notification service with WebSocket support, Redis pub/sub, and rate limiting.",
)
# Architect designs → Developer implements → Reviewer catches issues → Developer fixes → Tester adds tests

Tool Use

from autogen import register_function

def search_codebase(query: str, file_pattern: str = "*.py") -> str:
    """Search the codebase for specific patterns.

    Args:
        query: Search query (regex supported)
        file_pattern: File glob pattern to search in
    """
    import subprocess
    result = subprocess.run(["grep", "-rn", query, "--include", file_pattern, "."],
                           capture_output=True, text=True)
    return result.stdout[:2000]

def run_tests(test_path: str = "tests/") -> str:
    """Run pytest on the specified test directory.

    Args:
        test_path: Path to test files or directory
    """
    import subprocess
    result = subprocess.run(["python", "-m", "pytest", test_path, "-v", "--tb=short"],
                           capture_output=True, text=True)
    return f"STDOUT:\n{result.stdout}\nSTDERR:\n{result.stderr}"

# Register tools for specific agents
register_function(search_codebase, caller=developer, executor=user_proxy,
    description="Search the codebase for code patterns")
register_function(run_tests, caller=tester, executor=user_proxy,
    description="Run tests to verify code correctness")

Installation

pip install ag2                           # Or: pip install pyautogen

Best Practices

  1. Clear system messages — Define each agent's role precisely; vague instructions lead to unfocused conversations
  2. Speaker selection — Use auto for LLM-selected speakers in group chat; round_robin for predictable flow
  3. Termination conditions — Set is_termination_msg and max_consecutive_auto_reply; prevent infinite loops
  4. Docker for code execution — Enable use_docker: True for safe code execution; agents can run untrusted code
  5. Human-in-the-loop — Use TERMINATE mode for approval on critical actions; NEVER for fully autonomous
  6. Tool registration — Register tools with specific caller/executor pairs; not every agent needs every tool
  7. Nested chats — Use nested conversations for sub-tasks; agent can spawn a side conversation and return results
  8. Cost control — Set max_round and max_consecutive_auto_reply; monitor token usage in group chats

当前收录版本

1.0.0

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值85/100

亮点

  • 提供 AG2 多智能体框架的完整使用指南
  • 包含丰富的代码示例和实际应用场景
  • 面向开发者解决复杂任务协作需求
触发精准90/100

亮点

  • description 完整描述 AG2 专家角色和核心能力
  • 触发词覆盖多智能体、对话框架等关键概念
  • 边界清晰,不易与其他 Skill 重叠
结构规范95/100

亮点

  • 结构清晰,包含核心能力、代码示例、安装指南、最佳实践
  • 提供完整的端到端示例(Two-Agent、Group Chat、Tool Use)
  • frontmatter 完整,单文件长度适中
执行可靠90/100

亮点

  • 工具来源明确,参数正确,代码示例完整可执行
  • 覆盖主要异常处理(termination conditions、max_round控制)
  • 提供 Docker 安全执行和 human-in-the-loop 确认机制
证据可验 (前四项均值)90/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

  • 安装或获取外部依赖

    使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。

    主文档提及 · 第 149 行
  • 调用命令或脚本

    先读脚本与参数,使用普通权限和限定目录;安装或执行前由使用工具再次确认。

    主文档提及 · 第 124, 135 行

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。