openai-agents
OpenAI Agents SDKのエキスパートとして、ツール連携や安全制御機能を備えた高性能AIエージェントを開発し、タスクの委譲や実行を効率化することで、ビジネス課題を解決するシステム構築を支援するSkill。
📜 元の英語説明(参考)
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.
🇯🇵 日本人クリエイター向け解説
OpenAI Agents SDKのエキスパートとして、ツール連携や安全制御機能を備えた高性能AIエージェントを開発し、タスクの委譲や実行を効率化することで、ビジネス課題を解決するシステム構築を支援するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o openai-agents.zip https://jpskill.com/download/15200.zip && unzip -o openai-agents.zip && rm openai-agents.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/15200.zip -OutFile "$d\openai-agents.zip"; Expand-Archive "$d\openai-agents.zip" -DestinationPath $d -Force; ri "$d\openai-agents.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
openai-agents.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
openai-agentsフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
OpenAI Agents SDK — 本番環境向け AI エージェントの構築
あなたは、マルチエージェントシステムを構築するための公式フレームワークである OpenAI Agents SDK (旧 Swarm) の専門家です。開発者が、ツール呼び出し、ガードレール、エージェントのハンドオフ、ストリーミング、トレース、および MCP 統合を使用してエージェントを作成し、調整、タスクの委任、および組み込みの安全制御を備えたツールを実行する、本番環境グレードの AI エージェントを構築するのを支援します。
主要な機能
エージェントの定義
# agents/customer_support.py — マルチエージェントの顧客サポートシステム
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:
"""ID で注文を検索します。
Args:
order_id: 注文識別子 (例: 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:
"""注文の払い戻しを開始します。
Args:
order_id: 払い戻し対象の注文
reason: 払い戻しの理由
"""
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:
"""問題が複雑すぎる場合に、人間のエージェントにエスカレートします。
Args:
summary: 人間のエージェントへの問題の簡単な要約
"""
ticket = await support.create_ticket(summary, priority="high")
return f"Escalated to human agent. Ticket: {ticket.id}"
# トリアージエージェント — 適切なスペシャリストにルーティングします
triage_agent = Agent(
name="Triage",
instructions="""あなたは顧客サポートのトリアージエージェントです。
顧客の問題を特定し、適切なスペシャリストに引き渡します。
- 注文の問題 → 注文スペシャリスト
- 請求/払い戻し → 請求スペシャリスト
- 技術的な問題 → 人間にエスカレート""",
handoffs=["order_specialist", "billing_specialist"],
tools=[escalate_to_human],
)
# スペシャリストエージェント
order_specialist = Agent(
name="Order Specialist",
instructions="注文関連の問い合わせに対応します。注文を検索し、ステータスの更新を提供し、変更を支援します。",
tools=[lookup_order],
handoffs=["billing_specialist"], # 必要に応じて請求に引き継ぐことができます
)
billing_specialist = Agent(
name="Billing Specialist",
instructions="請求および払い戻しのリクエストを処理します。払い戻しを処理する前に注文を確認します。承認なしの最大払い戻し額: $500。",
tools=[lookup_order, initiate_refund],
)
ガードレール
# 入力ガードレール — エージェントがメッセージを処理する前に実行されます
class ContentCheck(BaseModel):
is_appropriate: bool
reasoning: str
async def content_guardrail(ctx, agent, input) -> GuardrailFunctionOutput:
"""ユーザー入力が処理前に適切かどうかを確認します。"""
result = await Runner.run(
Agent(
name="Content Checker",
instructions="入力が正当な顧客サポートリクエストであるかどうかを確認します。不適切なコンテンツにフラグを立てます。",
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"],
)
エージェントの実行
from agents import Runner
# シングルターン
result = await Runner.run(
triage_agent,
"I want a refund for order ORD-12345, the product arrived damaged",
)
print(result.final_output)
# エージェントフロー: Triage → Billing Specialist → lookup_order → initiate_refund
# ストリーミング
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}]")
# MCP サーバーを使用
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")
インストール
pip install openai-agents
ベストプラクティス
- トリアージ + スペシャリスト — ルーティングにはトリアージエージェントを使用し、ドメイン固有のタスクにはスペシャリストエージェントを使用します。
- ガードレール — コンテンツフィルタリング、PII 検出、ポリシーの適用には、入力/出力ガードレールを追加します。
- ハンドオフ — エージェントの委任にはハンドオフを使用します。すべてのツールを備えた 1 つの巨大なエージェントよりも安価です。
- 構造化された出力 — 型付きで検証済みのエージェント応答には、Pydantic モデルで
output_typeを使用します。 - ツールの設計 — ツールを焦点化します (それぞれ 1 つのアクション)。明確なドキュメント文字列は、エージェントがツールを正しく使用するのに役立ちます。
- トレース — エージェントの決定、ツールの呼び出し、およびハンドオフチェーンのデバッグのためにトレースを有効にします。
- MCP 統合 — カスタムツールなしで、ファイルアクセス、データベースクエリ、API 呼び出しのために MCP サーバーを接続します。
- ストリーミング — リアルタイム出力には
run_streamedを使用します。透明性のために、ツールの呼び出しとハンドオフをユーザーに表示します。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
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
- Triage + specialists — Use a triage agent for routing; specialist agents for domain-specific tasks
- Guardrails — Add input/output guardrails for content filtering, PII detection, policy enforcement
- Handoffs — Use handoffs for agent delegation; cheaper than one mega-agent with all tools
- Structured output — Use
output_typewith Pydantic models for typed, validated agent responses - Tool design — Make tools focused (one action each); clear docstrings help the agent use them correctly
- Tracing — Enable tracing for debugging agent decisions, tool calls, and handoff chains
- MCP integration — Connect MCP servers for file access, database queries, API calls without custom tools
- Streaming — Use
run_streamedfor real-time output; show tool calls and handoffs to users for transparency