openai-agents

The official OpenAI Agents SDK (formerly Swarm) framework for building multi-agent systems. Helps developers create agents with tool calling, guardrails, agent handoffs, streaming, tracing, and MCP integration; supports building production-grade AI agents that coordinate, delegate tasks, and execute tools, with built-in safety controls.

Last repository push
GitHub Stars
219
Forks
38
Issues / PRs
1

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "openai-agents" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-9174ac9dae14d1518eb175bd7e70f9c22a85b0325a244a73f5bfd42ed3c76687. Verify the upstream source and version against https://github.com/TerminalSkills/skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

The official OpenAI Agents SDK (formerly Swarm) framework for building multi-agent systems. Helps developers create agents with tool calling, guardrails, agent handoffs, streaming, tracing, and MCP integration; supports building production-grade AI agents that coordinate, delegate tasks, and execute tools, with built-in safety controls.

0 Downloads

Introduction source: third_party · TerminalSkills · 1.0.0 Reference

SkillPi interpretation

Inputs and outputs
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"
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
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

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

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

Highlights

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

Areas to improve

  • 缺少 When to Use 章节 Reported severity: Minor

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

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

Highlights

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

Highlights

  • 工具来源明确,基于 OpenAI Agents SDK 官方框架
  • 包含完整的防护机制(guardrails)和安全控制,确保执行可靠性
Evidence Verifiability (mean of the first four)88/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

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

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

  • Install or fetch external dependencies

    Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.

    Mentioned in main document · lines 165, 177

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.