openai-agents

OpenAI Agents SDK(前身为 Swarm)的官方框架,用于构建多智能体系统。帮助开发者创建具备工具调用、防护措施、智能体交接、流式传输、追踪和 MCP 集成功能的智能体,支持协调、任务委派与执行工具的生产级 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 详情页并定位 "openai-agents":https://skillpi.com/zh/skills/deepskill-9174ac9dae14d1518eb175bd7e70f9c22a85b0325a244a73f5bfd42ed3c76687。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

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

安装实测待补充

OpenAI Agents SDK(前身为 Swarm)的官方框架,用于构建多智能体系统。帮助开发者创建具备工具调用、防护措施、智能体交接、流式传输、追踪和 MCP 集成功能的智能体,支持协调、任务委派与执行工具的生产级 AI 智能体,并内置安全控制机制。

0 下载

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

SkillPi 解读

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

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: openai-agents
description: >-
  You are an expert in the OpenAI Agents SDK (formerly Swarm), the official
  framework for building multi-agent systems. You help developers create
  agents with tool calling, guardrails, agent handoffs, streaming, tracing,
  and MCP integration — building production-grade AI agents that coordinate,
  delegate tasks, and execute tools with built-in safety controls.
license: Apache-2.0
compatibility: ''
metadata:
  author: terminal-skills
  version: 1.0.0
  category: AI & Machine Learning
  tags:
    - openai
    - agents
    - tools
    - guardrails
    - handoff
    - multi-agent
    - python

OpenAI Agents SDK — Build Production AI Agents

You are an expert in the OpenAI Agents SDK (formerly Swarm), the official framework for building multi-agent systems. You help developers create agents with tool calling, guardrails, agent handoffs, streaming, tracing, and MCP integration — building production-grade AI agents that coordinate, delegate tasks, and execute tools with built-in safety controls.

Core Capabilities

Agent Definition

# agents/customer_support.py — Multi-agent customer support system
from agents import Agent, Runner, function_tool, GuardrailFunctionOutput, InputGuardrail
from pydantic import BaseModel

class OrderInfo(BaseModel):
    order_id: str
    status: str
    total: float
    items: list[str]

@function_tool
async def lookup_order(order_id: str) -> OrderInfo:
    """Look up an order by ID.

    Args:
        order_id: The order identifier (e.g., ORD-12345)
    """
    order = await db.orders.find_by_id(order_id)
    return OrderInfo(
        order_id=order.id,
        status=order.status,
        total=order.total,
        items=[item.name for item in order.items],
    )

@function_tool
async def initiate_refund(order_id: str, reason: str) -> str:
    """Initiate a refund for an order.

    Args:
        order_id: The order to refund
        reason: Reason for the refund
    """
    result = await payments.refund(order_id, reason)
    return f"Refund initiated: ${result.amount}. Reference: {result.reference_id}"

@function_tool
async def escalate_to_human(summary: str) -> str:
    """Escalate to a human agent when the issue is too complex.

    Args:
        summary: Brief summary of the issue for the human agent
    """
    ticket = await support.create_ticket(summary, priority="high")
    return f"Escalated to human agent. Ticket: {ticket.id}"

# Triage agent — routes to the right specialist
triage_agent = Agent(
    name="Triage",
    instructions="""You are a customer support triage agent.
    Determine the customer's issue and hand off to the appropriate specialist:
    - Order issues → Order Specialist
    - Billing/refund → Billing Specialist
    - Technical problems → escalate to human""",
    handoffs=["order_specialist", "billing_specialist"],
    tools=[escalate_to_human],
)

# Specialist agents
order_specialist = Agent(
    name="Order Specialist",
    instructions="You handle order-related inquiries. Look up orders, provide status updates, and help with modifications.",
    tools=[lookup_order],
    handoffs=["billing_specialist"],       # Can hand off to billing if needed
)

billing_specialist = Agent(
    name="Billing Specialist",
    instructions="You handle billing and refund requests. Verify orders before processing refunds. Maximum refund without approval: $500.",
    tools=[lookup_order, initiate_refund],
)

Guardrails

# Input guardrail — runs before the agent processes the message
class ContentCheck(BaseModel):
    is_appropriate: bool
    reasoning: str

async def content_guardrail(ctx, agent, input) -> GuardrailFunctionOutput:
    """Check if user input is appropriate before processing."""
    result = await Runner.run(
        Agent(
            name="Content Checker",
            instructions="Check if the input is a legitimate customer support request. Flag inappropriate content.",
            output_type=ContentCheck,
        ),
        input,
        context=ctx,
    )
    return GuardrailFunctionOutput(
        output_info=result.final_output,
        tripwire_triggered=not result.final_output.is_appropriate,
    )

triage_agent = Agent(
    name="Triage",
    instructions="...",
    input_guardrails=[InputGuardrail(guardrail_function=content_guardrail)],
    handoffs=["order_specialist", "billing_specialist"],
)

Running Agents

from agents import Runner

# Single turn
result = await Runner.run(
    triage_agent,
    "I want a refund for order ORD-12345, the product arrived damaged",
)
print(result.final_output)
# Agent flow: Triage → Billing Specialist → lookup_order → initiate_refund

# Streaming
async for event in Runner.run_streamed(triage_agent, user_message):
    if event.type == "raw_response_event":
        if hasattr(event.data, "delta"):
            print(event.data.delta, end="")
    elif event.type == "agent_updated_stream_event":
        print(f"\n[Handed off to: {event.new_agent.name}]")
    elif event.type == "tool_call_event":
        print(f"\n[Calling tool: {event.tool_name}]")

# With MCP servers
from agents.mcp import MCPServerStdio

async with MCPServerStdio(command="npx", args=["-y", "@modelcontextprotocol/server-filesystem", "/data"]) as mcp:
    agent = Agent(
        name="File Assistant",
        instructions="Help users manage files",
        mcp_servers=[mcp],
    )
    result = await Runner.run(agent, "List all Python files in /data")

Installation

pip install openai-agents

Best Practices

  1. Triage + specialists — Use a triage agent for routing; specialist agents for domain-specific tasks
  2. Guardrails — Add input/output guardrails for content filtering, PII detection, policy enforcement
  3. Handoffs — Use handoffs for agent delegation; cheaper than one mega-agent with all tools
  4. Structured output — Use output_type with Pydantic models for typed, validated agent responses
  5. Tool design — Make tools focused (one action each); clear docstrings help the agent use them correctly
  6. Tracing — Enable tracing for debugging agent decisions, tool calls, and handoff chains
  7. MCP integration — Connect MCP servers for file access, database queries, API calls without custom tools
  8. Streaming — Use run_streamed for real-time output; show tool calls and handoffs to users for transparency

当前收录版本

1.0.0

核对来源版本 ↗

质量评测

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

场景价值85/100

亮点

  • 提供 OpenAI Agents SDK 的完整使用指南,涵盖多智能体系统构建的核心功能
  • 面向开发者群体,解决 AI 智能体开发的实际需求,具有明确的技术价值
触发精准88/100

亮点

  • description 完整描述了 Skill 的核心能力,触发词覆盖合理
  • 标签准确反映了 Skill 的技术栈和应用场景
结构规范92/100

待提升项

  • 缺少 When to Use 章节 原报告严重程度:轻微

    文档结构完整但缺少明确的 When to Use 使用场景说明章节

    改进建议:建议添加 When to Use 章节,明确说明该 Skill 适用的具体场景和使用时机

亮点

  • 结构清晰,包含核心能力、安装指南和最佳实践
  • 提供完整的代码示例,涵盖 Agent 定义、防护措施、运行方式等关键功能
执行可靠87/100

亮点

  • 工具来源明确,基于 OpenAI Agents SDK 官方框架
  • 包含完整的防护机制(guardrails)和安全控制,确保执行可靠性
证据可验 (前四项均值)88/100

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

正文静态检测

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

正文未命中当前规则。

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

权限与使用前检查

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

  • 安装或获取外部依赖

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

    主文档提及 · 第 165, 177 行

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

安全评级与访问范围

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

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