openai-agents
БесплатноБез исполняемых скриптовНе проверенThe OpenAI Agents SDK is a Python framework (openai-agents) for building agents that call tools, hand work to other agents, run guardrails and stream results…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
OpenAI Agents SDK
Overview
The OpenAI Agents SDK (pip install openai-agents, import name agents; version 0.24.0 checked, Python 3.10+) is the production successor to the experimental Swarm project. Its small set of primitives: Agent (instructions plus tools), handoffs and agents-as-tools for delegation, guardrails for validating input and output, sessions for memory, and built-in tracing. It uses the Responses API by default for OpenAI models. A JavaScript version exists as @openai/agents; this skill covers the Python SDK.
Instructions
- Install and set the key:
pip install openai-agents,export OPENAI_API_KEY=.... - Create agents with
Agent(name=..., instructions=..., tools=[...], model=...). Run withRunner.run_sync(agent, text)in scripts,await Runner.run(agent, text)in async code; readresult.final_output. - Tools: decorate a function with
@function_tool. The schema comes from type hints and the docstring (Google-styleArgs:descriptions). Hosted tools such asWebSearchToolcan go in the sametoolslist. - Handoffs:
handoffs=[billing_agent]takesAgentobjects (orhandoff(...)wrappers), not name strings, so define the specialists first. A handoff transfers the conversation; useagent.as_tool(...)instead when the main agent should keep control and just call another agent. - Typed output:
output_type=SomePydanticModelmakesfinal_outputa validated object. - Input guardrails: decorate
async def check(ctx, agent, input) -> GuardrailFunctionOutputwith@input_guardrailand passinput_guardrails=[check]. Whentripwire_triggered=Truethe run raisesInputGuardrailTripwireTriggered; catch it. Output guardrails work the same with@output_guardrail. - Streaming:
result = Runner.run_streamed(agent, input=...)(not awaited), thenasync for event in result.stream_events(). Event types areraw_response_event(tokens; checkisinstance(event.data, ResponseTextDeltaEvent)fromopenai.types.responses),run_item_stream_event(event.namesuch astool_called,tool_output,message_output_created) andagent_updated_stream_event(after a handoff). - MCP:
MCPServerStdio(params={"command": "npx", "args": [...]})as an async context manager, thenAgent(mcp_servers=[server]). Also available:MCPServerStreamableHttp(params={"url": ..., "headers": ...})andHostedMCPTool(the Responses API connects to the server itself).cache_tools_list=Trueis safe only if the tool list rarely changes. - Tracing is on by default and uploads to the OpenAI dashboard; disable with
OPENAI_AGENTS_DISABLE_TRACING=1orset_tracing_disabled(True)when data must not leave your environment.
Examples
Example 1: Triage agent with a billing specialist
User request: "Route refund questions to a billing agent that can look up orders."
import asyncio
from agents import Agent, Runner, function_tool
@function_tool
def lookup_order(order_id: str) -> str:
"""Look up an order.
Args:
order_id: The order identifier, for example ORD-12345
"""
return "ORD-12345: delivered 2026-10-02, total $48.00, status damaged-on-arrival"
billing = Agent(
name="Billing Specialist",
instructions="Handle refunds. Always look up the order first.",
tools=[lookup_order],
)
triage = Agent(
name="Triage",
instructions="Send billing and refund questions to the Billing Specialist.",
handoffs=[billing],
)
async def main():
result = await Runner.run(triage, "Refund order ORD-12345, it arrived damaged")
print(result.final_output)
asyncio.run(main())
Result: the trace shows Triage handing off to Billing Specialist, one lookup_order call, then a reply about the refund.
Example 2: Block off-topic input with a guardrail
User request: "Reject messages that are not support requests before the main agent runs."
# The `await`/`async for` lines in Examples 2 and 3 must run inside an `async def` (as in Example 1) or a notebook.
from pydantic import BaseModel
from agents import (Agent, Runner, GuardrailFunctionOutput, RunContextWrapper,
input_guardrail, InputGuardrailTripwireTriggered)
class Check(BaseModel):
is_support_request: bool
checker = Agent(name="Checker", instructions="Is this a customer support request?", output_type=Check)
@input_guardrail
async def only_support(ctx: RunContextWrapper[None], agent: Agent, user_input) -> GuardrailFunctionOutput:
res = await Runner.run(checker, user_input, context=ctx.context)
return GuardrailFunctionOutput(output_info=res.final_output,
tripwire_triggered=not res.final_output.is_support_request)
support = Agent(name="Support", instructions="Help with orders.", input_guardrails=[only_support])
try:
await Runner.run(support, "Write me a poem about cats")
except InputGuardrailTripwireTriggered:
print("Sorry, I can only help with orders.")
Result: the poem
Установить openai-agents в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл openai-agents?
The OpenAI Agents SDK is a Python framework (openai-agents) for building agents that call tools, hand work to other agents, run guardrails and stream results, with built-in tracing and MCP support. Use when building a multi-agent workflow with OpenAI models, adding function tools, handoffs, input guardrails or sessions, or when the user mentions openai-agents, Runner.run, or the Agents SDK (the successor to Swarm).
Как установить скилл openai-agents?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл openai-agents запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic