openai-agents-sdk

Par mkurman · zorai

OpenAI Agents SDK — créez des workflows agentiques avec handoffs, guardrails et intégration d'outils. Orchestration d'un agent unique jusqu'au multi-agent. Tracing et observabilité. SDK Python-first d'OpenAI.

npx skills add https://github.com/mkurman/zorai --skill openai-agents-sdk

Aperçu

OpenAI Agents SDK fournit un framework léger pour construire des workflows d'IA agentic. Supporte l'utilisation d'outils, les handoffs (routage agent-à-agent), les guardrails et le tracing — construit sur les primitives agent natives de l'API OpenAI.

Installation

uv pip install openai-agents

Agent basique

from agents import Agent, Runner

agent = Agent(name="Helper", instructions="You are a helpful assistant.")
result = Runner.run_sync(agent, "What is the capital of France?")
print(result.final_output)

Utilisation d'outils

from agents import Agent, Runner, function_tool

@function_tool
def get_weather(city: str) -> str:
    return f"Weather in {city}: sunny, 22°C"

agent = Agent(name="WeatherBot", instructions="Use tools to answer weather queries.", tools=[get_weather])
result = Runner.run_sync(agent, "What's the weather in London?")
print(result.final_output)

Handoffs

from agents import Agent, Runner

triage = Agent(name="Triage", instructions="Route to the right specialist.")
billing = Agent(name="Billing", instructions="Handle billing questions.")
triage.handoffs = [billing]

result = Runner.run_sync(triage, "My invoice didn't arrive")

Références

Skills similaires